Commit e98ea774 authored by Linus Walleij's avatar Linus Walleij

pinctrl/nomadik: basic Nomadik pinctrl interface

This adds a scratch pin control interface to the Nomadik pinctrl
driver, and defines the pins and groups in the DB8500 ASIC. We
define GPIO ranges to cover the pins exposed. The DB8500 has
more pins than this but we restrict the driver to the pins that
can be controlled from the combined GPIO and pin control hardware
to begin with.

ChangeLog v1->v2:
- Base on the latest pinctrl development from
  pinctrl-mergebase-20120418 so we can get rid of legacy
  group count mechanism. Also drop the range checks for group
  index, this is handled by the core now.
Acked-by: default avatarStephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Linus Walleij's avatarLinus Walleij <linus.walleij@linaro.org>
parent 072e82a1
...@@ -9,6 +9,8 @@ config UX500_SOC_COMMON ...@@ -9,6 +9,8 @@ config UX500_SOC_COMMON
select ARM_ERRATA_754322 select ARM_ERRATA_754322
select ARM_ERRATA_764369 select ARM_ERRATA_764369
select CACHE_L2X0 select CACHE_L2X0
select PINCTRL
select PINCTRL_NOMADIK
config UX500_SOC_DB5500 config UX500_SOC_DB5500
bool bool
...@@ -20,6 +22,7 @@ config UX500_SOC_DB8500 ...@@ -20,6 +22,7 @@ config UX500_SOC_DB8500
select REGULATOR select REGULATOR
select REGULATOR_DB8500_PRCMU select REGULATOR_DB8500_PRCMU
select CPU_FREQ_TABLE if CPU_FREQ select CPU_FREQ_TABLE if CPU_FREQ
select PINCTRL_DB8500
menu "Ux500 target platform (boards)" menu "Ux500 target platform (boards)"
......
...@@ -141,6 +141,7 @@ static void __init db8500_add_gpios(struct device *parent) ...@@ -141,6 +141,7 @@ static void __init db8500_add_gpios(struct device *parent)
dbx500_add_gpios(parent, ARRAY_AND_SIZE(db8500_gpio_base), dbx500_add_gpios(parent, ARRAY_AND_SIZE(db8500_gpio_base),
IRQ_DB8500_GPIO0, &pdata); IRQ_DB8500_GPIO0, &pdata);
dbx500_add_pinctrl(parent, "pinctrl-db8500");
} }
static int usb_db8500_rx_dma_cfg[] = { static int usb_db8500_rx_dma_cfg[] = {
......
...@@ -93,4 +93,16 @@ struct nmk_gpio_platform_data; ...@@ -93,4 +93,16 @@ struct nmk_gpio_platform_data;
void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num, void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
int irq, struct nmk_gpio_platform_data *pdata); int irq, struct nmk_gpio_platform_data *pdata);
static inline void
dbx500_add_pinctrl(struct device *parent, const char *name)
{
struct platform_device_info pdevinfo = {
.parent = parent,
.name = name,
.id = -1,
};
platform_device_register_full(&pdevinfo);
}
#endif #endif
...@@ -36,6 +36,14 @@ config PINCTRL_MMP2 ...@@ -36,6 +36,14 @@ config PINCTRL_MMP2
select PINCTRL_PXA3xx select PINCTRL_PXA3xx
select PINCONF select PINCONF
config PINCTRL_NOMADIK
bool "Nomadik pin controller driver"
depends on ARCH_U8500
config PINCTRL_DB8500
bool "DB8500 pin controller driver"
depends on PINCTRL_NOMADIK && ARCH_U8500
config PINCTRL_PXA168 config PINCTRL_PXA168
bool "PXA168 pin controller driver" bool "PXA168 pin controller driver"
depends on ARCH_MMP depends on ARCH_MMP
......
...@@ -11,7 +11,8 @@ endif ...@@ -11,7 +11,8 @@ endif
obj-$(CONFIG_GENERIC_PINCONF) += pinconf-generic.o obj-$(CONFIG_GENERIC_PINCONF) += pinconf-generic.o
obj-$(CONFIG_PINCTRL_PXA3xx) += pinctrl-pxa3xx.o obj-$(CONFIG_PINCTRL_PXA3xx) += pinctrl-pxa3xx.o
obj-$(CONFIG_PINCTRL_MMP2) += pinctrl-mmp2.o obj-$(CONFIG_PINCTRL_MMP2) += pinctrl-mmp2.o
obj-$(CONFIG_PLAT_NOMADIK) += pinctrl-nomadik.o obj-$(CONFIG_PINCTRL_NOMADIK) += pinctrl-nomadik.o
obj-$(CONFIG_PINCTRL_DB8500) += pinctrl-nomadik-db8500.o
obj-$(CONFIG_PINCTRL_PXA168) += pinctrl-pxa168.o obj-$(CONFIG_PINCTRL_PXA168) += pinctrl-pxa168.o
obj-$(CONFIG_PINCTRL_PXA910) += pinctrl-pxa910.o obj-$(CONFIG_PINCTRL_PXA910) += pinctrl-pxa910.o
obj-$(CONFIG_PINCTRL_SIRF) += pinctrl-sirf.o obj-$(CONFIG_PINCTRL_SIRF) += pinctrl-sirf.o
......
This diff is collapsed.
...@@ -24,12 +24,15 @@ ...@@ -24,12 +24,15 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pinctrl/pinctrl.h>
#include <asm/mach/irq.h> #include <asm/mach/irq.h>
#include <plat/pincfg.h> #include <plat/pincfg.h>
#include <plat/gpio-nomadik.h> #include <plat/gpio-nomadik.h>
#include "pinctrl-nomadik.h"
/* /*
* The GPIO module in the Nomadik family of Systems-on-Chip is an * The GPIO module in the Nomadik family of Systems-on-Chip is an
* AMBA device, managing 32 pins and alternate functions. The logic block * AMBA device, managing 32 pins and alternate functions. The logic block
...@@ -64,6 +67,12 @@ struct nmk_gpio_chip { ...@@ -64,6 +67,12 @@ struct nmk_gpio_chip {
u32 lowemi; u32 lowemi;
}; };
struct nmk_pinctrl {
struct device *dev;
struct pinctrl_dev *pctl;
const struct nmk_pinctrl_soc_data *soc;
};
static struct nmk_gpio_chip * static struct nmk_gpio_chip *
nmk_gpio_chips[DIV_ROUND_UP(ARCH_NR_GPIOS, NMK_GPIO_PER_CHIP)]; nmk_gpio_chips[DIV_ROUND_UP(ARCH_NR_GPIOS, NMK_GPIO_PER_CHIP)];
...@@ -1282,6 +1291,98 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) ...@@ -1282,6 +1291,98 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
return ret; return ret;
} }
static int nmk_get_groups_cnt(struct pinctrl_dev *pctldev)
{
struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
return npct->soc->ngroups;
}
static const char *nmk_get_group_name(struct pinctrl_dev *pctldev,
unsigned selector)
{
struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
return npct->soc->groups[selector].name;
}
static int nmk_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector,
const unsigned **pins,
unsigned *num_pins)
{
struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
*pins = npct->soc->groups[selector].pins;
*num_pins = npct->soc->groups[selector].npins;
return 0;
}
static void nmk_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
unsigned offset)
{
seq_printf(s, " Nomadik GPIO");
}
static struct pinctrl_ops nmk_pinctrl_ops = {
.get_groups_count = nmk_get_groups_cnt,
.get_group_name = nmk_get_group_name,
.get_group_pins = nmk_get_group_pins,
.pin_dbg_show = nmk_pin_dbg_show,
};
static struct pinctrl_desc nmk_pinctrl_desc = {
.name = "pinctrl-nomadik",
.pctlops = &nmk_pinctrl_ops,
.owner = THIS_MODULE,
};
static int __devinit nmk_pinctrl_probe(struct platform_device *pdev)
{
const struct platform_device_id *platid = platform_get_device_id(pdev);
struct nmk_pinctrl *npct;
int i;
npct = devm_kzalloc(&pdev->dev, sizeof(*npct), GFP_KERNEL);
if (!npct)
return -ENOMEM;
/* Poke in other ASIC variants here */
if (platid->driver_data == PINCTRL_NMK_DB8500)
nmk_pinctrl_db8500_init(&npct->soc);
/*
* We need all the GPIO drivers to probe FIRST, or we will not be able
* to obtain references to the struct gpio_chip * for them, and we
* need this to proceed.
*/
for (i = 0; i < npct->soc->gpio_num_ranges; i++) {
if (!nmk_gpio_chips[i]) {
dev_warn(&pdev->dev, "GPIO chip %d not registered yet\n", i);
devm_kfree(&pdev->dev, npct);
return -EPROBE_DEFER;
}
npct->soc->gpio_ranges[i].gc = &nmk_gpio_chips[i]->chip;
}
nmk_pinctrl_desc.pins = npct->soc->pins;
nmk_pinctrl_desc.npins = npct->soc->npins;
npct->dev = &pdev->dev;
npct->pctl = pinctrl_register(&nmk_pinctrl_desc, &pdev->dev, npct);
if (!npct->pctl) {
dev_err(&pdev->dev, "could not register Nomadik pinctrl driver\n");
return -EINVAL;
}
/* We will handle a range of GPIO pins */
for (i = 0; i < npct->soc->gpio_num_ranges; i++)
pinctrl_add_gpio_range(npct->pctl, &npct->soc->gpio_ranges[i]);
platform_set_drvdata(pdev, npct);
dev_info(&pdev->dev, "initialized Nomadik pin control driver\n");
return 0;
}
static const struct of_device_id nmk_gpio_match[] = { static const struct of_device_id nmk_gpio_match[] = {
{ .compatible = "st,nomadik-gpio", }, { .compatible = "st,nomadik-gpio", },
{} {}
...@@ -1296,9 +1397,28 @@ static struct platform_driver nmk_gpio_driver = { ...@@ -1296,9 +1397,28 @@ static struct platform_driver nmk_gpio_driver = {
.probe = nmk_gpio_probe, .probe = nmk_gpio_probe,
}; };
static const struct platform_device_id nmk_pinctrl_id[] = {
{ "pinctrl-stn8815", PINCTRL_NMK_STN8815 },
{ "pinctrl-db8500", PINCTRL_NMK_DB8500 },
};
static struct platform_driver nmk_pinctrl_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "pinctrl-nomadik",
},
.probe = nmk_pinctrl_probe,
.id_table = nmk_pinctrl_id,
};
static int __init nmk_gpio_init(void) static int __init nmk_gpio_init(void)
{ {
return platform_driver_register(&nmk_gpio_driver); int ret;
ret = platform_driver_register(&nmk_gpio_driver);
if (ret)
return ret;
return platform_driver_register(&nmk_pinctrl_driver);
} }
core_initcall(nmk_gpio_init); core_initcall(nmk_gpio_init);
......
#ifndef PINCTRL_PINCTRL_NOMADIK_H
#define PINCTRL_PINCTRL_NOMADIK_H
#include <plat/gpio-nomadik.h>
/* Package definitions */
#define PINCTRL_NMK_STN8815 0
#define PINCTRL_NMK_DB8500 1
/**
* struct nmk_pingroup - describes a Nomadik pin group
* @name: the name of this specific pin group
* @pins: an array of discrete physical pins used in this group, taken
* from the driver-local pin enumeration space
* @num_pins: the number of pins in this group array, i.e. the number of
* elements in .pins so we can iterate over that array
* @altsetting: the altsetting to apply to all pins in this group to
* configure them to be used by a function
*/
struct nmk_pingroup {
const char *name;
const unsigned int *pins;
const unsigned npins;
u32 altsetting;
};
/**
* struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
* @gpio_ranges: An array of GPIO ranges for this SoC
* @gpio_num_ranges: The number of GPIO ranges for this SoC
* @pins: An array describing all pins the pin controller affects.
* All pins which are also GPIOs must be listed first within the
* array, and be numbered identically to the GPIO controller's
* numbering.
* @npins: The numbmer of entries in @pins.
* @groups: An array describing all pin groups the pin SoC supports.
* @ngroups: The number of entries in @groups.
*/
struct nmk_pinctrl_soc_data {
struct pinctrl_gpio_range *gpio_ranges;
unsigned gpio_num_ranges;
const struct pinctrl_pin_desc *pins;
unsigned npins;
const struct nmk_pingroup *groups;
unsigned ngroups;
};
#ifdef CONFIG_PINCTRL_DB8500
void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);
#else
static inline void
nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
{
}
#endif
#endif /* PINCTRL_PINCTRL_NOMADIK_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment