#include #include #include #include #include #define GPIO_REG_PORT 0x0 #define GPIO_REG_DIR 0x1 static int cds9k_gpio_probe(struct platform_device *pdev) { printk("Hello from the GPIO driver. Pdev name is %s\n", pdev->name); struct gpio_regmap_config config = {}; struct regmap *regmap; u32 base; int ret; const char *parent_name = dev_name(pdev->dev.parent); if (!pdev->dev.parent) { printk("NULL parent to platform device\n"); return -ENODEV; } ret = device_property_read_u32(&pdev->dev, "reg", &base); if (ret) { printk("Failed to get u32 reg property on platform device\n"); return -EINVAL; } regmap = dev_get_regmap(pdev->dev.parent, NULL); if (!regmap) { printk("dev_get_regmap failed\n"); 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 = 8; 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; printk("About to return from probe\n"); return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(&pdev->dev, &config)); //0; } 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");