99 * kind, whether express or implied.
1010 */
1111
12+ #include <linux/acpi.h>
1213#include <linux/kernel.h>
1314#include <linux/init.h>
1415#include <linux/spinlock.h>
1819#include <linux/of_address.h>
1920#include <linux/of_irq.h>
2021#include <linux/of_platform.h>
22+ #include <linux/property.h>
23+ #include <linux/mod_devicetable.h>
2124#include <linux/slab.h>
2225#include <linux/irq.h>
2326#include <linux/gpio/driver.h>
@@ -303,8 +306,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
303306 struct device_node * np = pdev -> dev .of_node ;
304307 struct mpc8xxx_gpio_chip * mpc8xxx_gc ;
305308 struct gpio_chip * gc ;
306- const struct mpc8xxx_gpio_devtype * devtype =
307- of_device_get_match_data ( & pdev -> dev ) ;
309+ const struct mpc8xxx_gpio_devtype * devtype = NULL ;
310+ struct fwnode_handle * fwnode ;
308311 int ret ;
309312
310313 mpc8xxx_gc = devm_kzalloc (& pdev -> dev , sizeof (* mpc8xxx_gc ), GFP_KERNEL );
@@ -315,14 +318,14 @@ static int mpc8xxx_probe(struct platform_device *pdev)
315318
316319 raw_spin_lock_init (& mpc8xxx_gc -> lock );
317320
318- mpc8xxx_gc -> regs = of_iomap ( np , 0 );
319- if (! mpc8xxx_gc -> regs )
320- return - ENOMEM ;
321+ mpc8xxx_gc -> regs = devm_platform_ioremap_resource ( pdev , 0 );
322+ if (IS_ERR ( mpc8xxx_gc -> regs ) )
323+ return PTR_ERR ( mpc8xxx_gc -> regs ) ;
321324
322325 gc = & mpc8xxx_gc -> gc ;
323326 gc -> parent = & pdev -> dev ;
324327
325- if (of_property_read_bool ( np , "little-endian" )) {
328+ if (device_property_read_bool ( & pdev -> dev , "little-endian" )) {
326329 ret = bgpio_init (gc , & pdev -> dev , 4 ,
327330 mpc8xxx_gc -> regs + GPIO_DAT ,
328331 NULL , NULL ,
@@ -345,6 +348,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
345348
346349 mpc8xxx_gc -> direction_output = gc -> direction_output ;
347350
351+ devtype = device_get_match_data (& pdev -> dev );
348352 if (!devtype )
349353 devtype = & mpc8xxx_gpio_devtype_default ;
350354
@@ -369,24 +373,29 @@ static int mpc8xxx_probe(struct platform_device *pdev)
369373 * associated input enable must be set (GPIOxGPIE[IEn]=1) to propagate
370374 * the port value to the GPIO Data Register.
371375 */
376+ fwnode = dev_fwnode (& pdev -> dev );
372377 if (of_device_is_compatible (np , "fsl,qoriq-gpio" ) ||
373378 of_device_is_compatible (np , "fsl,ls1028a-gpio" ) ||
374- of_device_is_compatible (np , "fsl,ls1088a-gpio" ))
379+ of_device_is_compatible (np , "fsl,ls1088a-gpio" ) ||
380+ is_acpi_node (fwnode ))
375381 gc -> write_reg (mpc8xxx_gc -> regs + GPIO_IBE , 0xffffffff );
376382
377383 ret = gpiochip_add_data (gc , mpc8xxx_gc );
378384 if (ret ) {
379- pr_err ( "%pOF: GPIO chip registration failed with status %d\n" ,
380- np , ret );
385+ dev_err ( & pdev -> dev ,
386+ "GPIO chip registration failed with status %d\n" , ret );
381387 goto err ;
382388 }
383389
384- mpc8xxx_gc -> irqn = irq_of_parse_and_map ( np , 0 );
390+ mpc8xxx_gc -> irqn = platform_get_irq ( pdev , 0 );
385391 if (!mpc8xxx_gc -> irqn )
386392 return 0 ;
387393
388- mpc8xxx_gc -> irq = irq_domain_add_linear (np , MPC8XXX_GPIO_PINS ,
389- & mpc8xxx_gpio_irq_ops , mpc8xxx_gc );
394+ mpc8xxx_gc -> irq = irq_domain_create_linear (fwnode ,
395+ MPC8XXX_GPIO_PINS ,
396+ & mpc8xxx_gpio_irq_ops ,
397+ mpc8xxx_gc );
398+
390399 if (!mpc8xxx_gc -> irq )
391400 return 0 ;
392401
@@ -399,8 +408,9 @@ static int mpc8xxx_probe(struct platform_device *pdev)
399408 IRQF_SHARED , "gpio-cascade" ,
400409 mpc8xxx_gc );
401410 if (ret ) {
402- dev_err (& pdev -> dev , "%s: failed to devm_request_irq(%d), ret = %d\n" ,
403- np -> full_name , mpc8xxx_gc -> irqn , ret );
411+ dev_err (& pdev -> dev ,
412+ "failed to devm_request_irq(%d), ret = %d\n" ,
413+ mpc8xxx_gc -> irqn , ret );
404414 goto err ;
405415 }
406416
@@ -425,12 +435,21 @@ static int mpc8xxx_remove(struct platform_device *pdev)
425435 return 0 ;
426436}
427437
438+ #ifdef CONFIG_ACPI
439+ static const struct acpi_device_id gpio_acpi_ids [] = {
440+ {"NXP0031" ,},
441+ { }
442+ };
443+ MODULE_DEVICE_TABLE (acpi , gpio_acpi_ids );
444+ #endif
445+
428446static struct platform_driver mpc8xxx_plat_driver = {
429447 .probe = mpc8xxx_probe ,
430448 .remove = mpc8xxx_remove ,
431449 .driver = {
432450 .name = "gpio-mpc8xxx" ,
433451 .of_match_table = mpc8xxx_gpio_ids ,
452+ .acpi_match_table = ACPI_PTR (gpio_acpi_ids ),
434453 },
435454};
436455
0 commit comments