HiSilicon driver updates for 6.1:

- some small improvements to the hisi_lpc driver
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEQeMYD8qOQTc1R/snC8hXbtmJZlwFAmMak30VHHh1d2VpNUBo
 aXNpbGljb24uY29tAAoJEAvIV27ZiWZct9YP/3oPv3yuzcDL9YuRxaT+ESclVy0A
 znkYe6zYT49O0nms0s9F9DJD+hE65I07hapa9F81NgWzxVbtCA8AVLAu6vqDxj3Z
 UuPr+g5ywISobaTD7bsJaBrxCS/nGxHJ8lOM4khfK9rdzXhQGtOcVxLj2DLLkzNb
 GvDAWOuWTGBQx0+0nfHt8v467pO3DcAqee+guBn3rf2KCGKnjYTCPuTvfch6OkzD
 G84owjHQLlU3jFA4Lgy6+uCq8V0s2QoFujZQ5fQ3DV/IgSrFWX9yvi9+Uv/X/+O/
 znAqefWv6DjWM0DHqmxehl5EuQxxKIBitlPfIneDJHWck9DeHIMpAldA7RsdthTU
 5io71m8kioPHdmuMf26zAtWfPQzO6pP3xnrtbyh164pjHi0GrUeus4HMPqC2Du3t
 Y1jJK2Ju4eVMbhgV5omOW6159LghYOVTnn5dEaVligwbIqeoLt8idXAkih/ecBCB
 3fafwXT2+8XDJ1DrJoKF/WtNTm9Dbx+JHFqhXfUDIvwK5TIMPU+t9On5z9GOY4sE
 Ukla/FkNrI3hDPByqq2NBbChvixGVz9uLVRH6EMxNPPbYrSYXPt97X7DY2AcxI9g
 RqBi7pXTalBaswKq/pOYGoJLi51QAamoXUMDzsrrPUURXauNp4TL4oOdf/Pt0mYa
 kkz+GLOITOArxFlA
 =Ldny
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmMt1iAACgkQmmx57+YA
 GNlZ4Q//RyUkdbBml/DUBCui/OEjBTHqviwMGlssMxJ8r895YMEO7f4D3gbTKttg
 oxcUBHTVqQh+UZh7NZwbwAbxh7nh2Zh7spX4jEtUaPfAaI2QKjLZeGtisdyy5Se2
 dOcnxk3Kwgj99NNYKiOnEfbG2Wxg7ghwdcINfPBFmSoyVvElZvKwhsE8EOlyDDRb
 pTYXTnb54Uc6eDvpEq/KRfUHUZso7/KsGPcI6FefFJUkMVoklHffmC2+zDVMtW2m
 MZUZSRbKpdy2g9mpLXak+hJMEgxdiShXwwYExwR/1K9ulsm+3ggAFwro9Jthqbp5
 N7JSytRByN/GqWmmHYNOMghuUCzm0MYystk4CLGcsxg4iL+i7sWiPwd30tnqzqqs
 SSOn8EcgPnvCE5TZehCgTd59JGOAxZOB3GiumRMDPhxVH6kMIoxOL/I48vOZELq6
 uMH6KYsNC70/LqjqxHRhP/BYi7+L/8NzZjiiU+gzK4aQIuMfz03EpwPoiWxuw+AH
 BKQryga6ivVwKKwmwAchpwEtAKxJQLqjLYAJa9MGkAeRCqbKs+Gf5xUytdPCfrJa
 yTnX40ysx8n3PNsAfe0s3ZzQt6f3XAWhljO+CKwoWFAnIAJV3EgffcufTylhwFT6
 azq0UWfa/YmaM/cFG3/dG7oAAFEEqQNbFwqVGYS+sRs+6JQRClU=
 =SGdi
 -----END PGP SIGNATURE-----

Merge tag 'hisi-drivers-for-6.1' of https://github.com/hisilicon/linux-hisi into arm/drivers

HiSilicon driver updates for 6.1:
- some small improvements to the hisi_lpc driver

* tag 'hisi-drivers-for-6.1' of https://github.com/hisilicon/linux-hisi:
  bus: hisi_lpc: Use platform_device_register_full()
  bus: hisi_lpc: Don't guard ACPI IDs with ACPI_PTR()
  bus: hisi_lpc: Correct error code for timeout
  bus: hisi_lpc: Use devm_platform_ioremap_resource
  bus: hisi_lpc: Don't dereference fwnode handle

Link: https://lore.kernel.org/r/631FE463.6070701@hisilicon.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Arnd Bergmann 2022-09-23 17:52:00 +02:00
commit 4cb59d5069

View File

@ -85,7 +85,7 @@ static int wait_lpc_idle(void __iomem *mbase, unsigned int waitcnt)
ndelay(LPC_NSEC_PERWAIT);
} while (--waitcnt);
return -ETIME;
return -ETIMEDOUT;
}
/*
@ -347,7 +347,7 @@ static int hisi_lpc_acpi_xlat_io_res(struct acpi_device *adev,
unsigned long sys_port;
resource_size_t len = resource_size(res);
sys_port = logic_pio_trans_hwaddr(&host->fwnode, res->start, len);
sys_port = logic_pio_trans_hwaddr(acpi_fwnode_handle(host), res->start, len);
if (sys_port == ~0UL)
return -EFAULT;
@ -472,9 +472,7 @@ static int hisi_lpc_acpi_clear_enumerated(struct acpi_device *adev, void *not_us
struct hisi_lpc_acpi_cell {
const char *hid;
const char *name;
void *pdata;
size_t pdata_size;
const struct platform_device_info *pdevinfo;
};
static void hisi_lpc_acpi_remove(struct device *hostdev)
@ -505,28 +503,45 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data)
/* ipmi */
{
.hid = "IPI0001",
.name = "hisi-lpc-ipmi",
.pdevinfo = (struct platform_device_info []) {
{
.parent = hostdev,
.fwnode = acpi_fwnode_handle(child),
.name = "hisi-lpc-ipmi",
.id = PLATFORM_DEVID_AUTO,
.res = res,
.num_res = num_res,
},
},
},
/* 8250-compatible uart */
{
.hid = "HISI1031",
.name = "serial8250",
.pdata = (struct plat_serial8250_port []) {
.pdevinfo = (struct platform_device_info []) {
{
.iobase = res->start,
.uartclk = 1843200,
.iotype = UPIO_PORT,
.flags = UPF_BOOT_AUTOCONF,
.parent = hostdev,
.fwnode = acpi_fwnode_handle(child),
.name = "serial8250",
.id = PLATFORM_DEVID_AUTO,
.res = res,
.num_res = num_res,
.data = (struct plat_serial8250_port []) {
{
.iobase = res->start,
.uartclk = 1843200,
.iotype = UPIO_PORT,
.flags = UPF_BOOT_AUTOCONF,
},
{}
},
.size_data = 2 * sizeof(struct plat_serial8250_port),
},
{}
},
.pdata_size = 2 *
sizeof(struct plat_serial8250_port),
},
{}
};
for (; cell && cell->name; cell++) {
for (; cell && cell->hid; cell++) {
if (!strcmp(cell->hid, hid)) {
found = true;
break;
@ -540,31 +555,12 @@ static int hisi_lpc_acpi_add_child(struct acpi_device *child, void *data)
return 0;
}
pdev = platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO);
if (!pdev)
return -ENOMEM;
pdev->dev.parent = hostdev;
ACPI_COMPANION_SET(&pdev->dev, child);
ret = platform_device_add_resources(pdev, res, num_res);
if (ret)
goto fail;
ret = platform_device_add_data(pdev, cell->pdata, cell->pdata_size);
if (ret)
goto fail;
ret = platform_device_add(pdev);
if (ret)
goto fail;
pdev = platform_device_register_full(cell->pdevinfo);
if (IS_ERR(pdev))
return PTR_ERR(pdev);
acpi_device_set_enumerated(child);
return 0;
fail:
platform_device_put(pdev);
return ret;
}
/*
@ -589,11 +585,6 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
return ret;
}
static const struct acpi_device_id hisi_lpc_acpi_match[] = {
{"HISI0191"},
{}
};
#else
static int hisi_lpc_acpi_probe(struct device *dev)
{
@ -615,11 +606,9 @@ static void hisi_lpc_acpi_remove(struct device *hostdev)
static int hisi_lpc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct acpi_device *acpi_device = ACPI_COMPANION(dev);
struct logic_pio_hwaddr *range;
struct hisi_lpc_dev *lpcdev;
resource_size_t io_end;
struct resource *res;
int ret;
lpcdev = devm_kzalloc(dev, sizeof(*lpcdev), GFP_KERNEL);
@ -628,8 +617,7 @@ static int hisi_lpc_probe(struct platform_device *pdev)
spin_lock_init(&lpcdev->cycle_lock);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
lpcdev->membase = devm_ioremap_resource(dev, res);
lpcdev->membase = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(lpcdev->membase))
return PTR_ERR(lpcdev->membase);
@ -637,7 +625,7 @@ static int hisi_lpc_probe(struct platform_device *pdev)
if (!range)
return -ENOMEM;
range->fwnode = dev->fwnode;
range->fwnode = dev_fwnode(dev);
range->flags = LOGIC_PIO_INDIRECT;
range->size = PIO_INDIRECT_SIZE;
range->hostdata = lpcdev;
@ -651,7 +639,7 @@ static int hisi_lpc_probe(struct platform_device *pdev)
}
/* register the LPC host PIO resources */
if (acpi_device)
if (is_acpi_device_node(range->fwnode))
ret = hisi_lpc_acpi_probe(dev);
else
ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
@ -672,11 +660,10 @@ static int hisi_lpc_probe(struct platform_device *pdev)
static int hisi_lpc_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct acpi_device *acpi_device = ACPI_COMPANION(dev);
struct hisi_lpc_dev *lpcdev = dev_get_drvdata(dev);
struct logic_pio_hwaddr *range = lpcdev->io_host;
if (acpi_device)
if (is_acpi_device_node(range->fwnode))
hisi_lpc_acpi_remove(dev);
else
of_platform_depopulate(dev);
@ -692,11 +679,16 @@ static const struct of_device_id hisi_lpc_of_match[] = {
{}
};
static const struct acpi_device_id hisi_lpc_acpi_match[] = {
{"HISI0191"},
{}
};
static struct platform_driver hisi_lpc_driver = {
.driver = {
.name = DRV_NAME,
.of_match_table = hisi_lpc_of_match,
.acpi_match_table = ACPI_PTR(hisi_lpc_acpi_match),
.acpi_match_table = hisi_lpc_acpi_match,
},
.probe = hisi_lpc_probe,
.remove = hisi_lpc_remove,