#include #include #include #include #include #define GPIO_REG_PORT 0x0 #define GPIO_REG_DIR 0x1 static int cds9k_gpio_probe(struct platform_device *pdev) { struct gpio_regmap_config config = {}; struct regmap *regmap; u32 base; int ret; if (!pdev->dev.parent) return -ENODEV; ret = device_property_read_u32(&pdev->dev, "reg", &base); if (ret) return -EINVAL; regmap = dev_get_regmap(pdev->dev.parent, NULL); if (!regmap) return -ENODEV; config.parent = &pdev->dev; config.regmap = regmap; /* XXX would be nice to use these if specified in DT config.names = config.label = */ config.ngpio = 16; config.reg_dat_base = base + GPIO_REG_PORT; config.reg_set_base = base + GPIO_REG_PORT; config.reg_dir_out_base = base + GPIO_REG_DIR; return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(&pdev->dev, &config)); } static struct of_device_id cds9k_gpio_of_match[] = { { .compatible = "david,cds9k-gpio" }, {} }; MODULE_DEVICE_TABLE(of, cds9k_gpio_of_match); static struct platform_driver cds9k_gpio = { .driver = { .name = "cds9k-gpio", .of_match_table = cds9k_gpio_of_match, }, .probe = cds9k_gpio_probe }; module_platform_driver(cds9k_gpio); MODULE_AUTHOR("David Phillips "); MODULE_DESCRIPTION("GPIO driver for the CDS9K board controller"); MODULE_LICENSE("GPL v2");