aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2014-03-21 05:40:24 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-03-25 04:57:07 -0400
commit8f18bcfcd2bc30cb9a5924a6b4af49c8388bc785 (patch)
treef27a4f2550ef8953b9587b05fcfa7d0f303893a1
parent194e15ba00d90a6e8779b9cd87f1feec0d55427f (diff)
pinctrl: nomadik: factor in platform data container
The old platform data struct is just a leftover from the times when the driver was not probed exclusively from the device tree. Factor this into the general state container and simplify the probe path. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index 41e808d9edb3..98a36a0969f9 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -246,19 +246,6 @@ enum nmk_gpio_slpm {
246 NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE, 246 NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE,
247}; 247};
248 248
249/*
250 * Platform data to register a block: only the initial gpio/irq number.
251 */
252struct nmk_gpio_platform_data {
253 char *name;
254 int first_gpio;
255 int first_irq;
256 int num_gpio;
257 u32 (*get_latent_status)(unsigned int bank);
258 void (*set_ioforce)(bool enable);
259 bool supports_sleepmode;
260};
261
262struct nmk_gpio_chip { 249struct nmk_gpio_chip {
263 struct gpio_chip chip; 250 struct gpio_chip chip;
264 struct irq_domain *domain; 251 struct irq_domain *domain;
@@ -1257,39 +1244,33 @@ static const struct irq_domain_ops nmk_gpio_irq_simple_ops = {
1257 1244
1258static int nmk_gpio_probe(struct platform_device *dev) 1245static int nmk_gpio_probe(struct platform_device *dev)
1259{ 1246{
1260 struct nmk_gpio_platform_data *pdata;
1261 struct device_node *np = dev->dev.of_node; 1247 struct device_node *np = dev->dev.of_node;
1262 struct nmk_gpio_chip *nmk_chip; 1248 struct nmk_gpio_chip *nmk_chip;
1263 struct gpio_chip *chip; 1249 struct gpio_chip *chip;
1264 struct resource *res; 1250 struct resource *res;
1265 struct clk *clk; 1251 struct clk *clk;
1266 int latent_irq; 1252 int latent_irq;
1253 bool supports_sleepmode;
1267 void __iomem *base; 1254 void __iomem *base;
1268 int irq; 1255 int irq;
1269 int ret; 1256 int ret;
1270 1257
1271 pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL);
1272 if (!pdata)
1273 return -ENOMEM;
1274
1275 if (of_get_property(np, "st,supports-sleepmode", NULL)) 1258 if (of_get_property(np, "st,supports-sleepmode", NULL))
1276 pdata->supports_sleepmode = true; 1259 supports_sleepmode = true;
1260 else
1261 supports_sleepmode = false;
1277 1262
1278 if (of_property_read_u32(np, "gpio-bank", &dev->id)) { 1263 if (of_property_read_u32(np, "gpio-bank", &dev->id)) {
1279 dev_err(&dev->dev, "gpio-bank property not found\n"); 1264 dev_err(&dev->dev, "gpio-bank property not found\n");
1280 return -EINVAL; 1265 return -EINVAL;
1281 } 1266 }
1282 1267
1283 pdata->first_gpio = dev->id * NMK_GPIO_PER_CHIP;
1284 pdata->num_gpio = NMK_GPIO_PER_CHIP;
1285
1286 irq = platform_get_irq(dev, 0); 1268 irq = platform_get_irq(dev, 0);
1287 if (irq < 0) 1269 if (irq < 0)
1288 return irq; 1270 return irq;
1289 1271
1272 /* It's OK for this IRQ not to be present */
1290 latent_irq = platform_get_irq(dev, 1); 1273 latent_irq = platform_get_irq(dev, 1);
1291 if (latent_irq >= 0 && !pdata->get_latent_status)
1292 return -EINVAL;
1293 1274
1294 res = platform_get_resource(dev, IORESOURCE_MEM, 0); 1275 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
1295 base = devm_ioremap_resource(&dev->dev, res); 1276 base = devm_ioremap_resource(&dev->dev, res);
@@ -1315,15 +1296,13 @@ static int nmk_gpio_probe(struct platform_device *dev)
1315 nmk_chip->chip = nmk_gpio_template; 1296 nmk_chip->chip = nmk_gpio_template;
1316 nmk_chip->parent_irq = irq; 1297 nmk_chip->parent_irq = irq;
1317 nmk_chip->latent_parent_irq = latent_irq; 1298 nmk_chip->latent_parent_irq = latent_irq;
1318 nmk_chip->get_latent_status = pdata->get_latent_status; 1299 nmk_chip->sleepmode = supports_sleepmode;
1319 nmk_chip->set_ioforce = pdata->set_ioforce;
1320 nmk_chip->sleepmode = pdata->supports_sleepmode;
1321 spin_lock_init(&nmk_chip->lock); 1300 spin_lock_init(&nmk_chip->lock);
1322 1301
1323 chip = &nmk_chip->chip; 1302 chip = &nmk_chip->chip;
1324 chip->base = pdata->first_gpio; 1303 chip->base = dev->id * NMK_GPIO_PER_CHIP;
1325 chip->ngpio = pdata->num_gpio; 1304 chip->ngpio = NMK_GPIO_PER_CHIP;
1326 chip->label = pdata->name ?: dev_name(&dev->dev); 1305 chip->label = dev_name(&dev->dev);
1327 chip->dev = &dev->dev; 1306 chip->dev = &dev->dev;
1328 chip->owner = THIS_MODULE; 1307 chip->owner = THIS_MODULE;
1329 1308