From d4e62d0094e1b0f69946c3f16ce8ec882302a461 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Dec 2012 23:50:43 +0100 Subject: sh-pfc: Split platform data from the sh_pfc structure Create a sh_pfc_platform_data structure to store platform data and reference it from the core sh_pfc structure. Signed-off-by: Laurent Pinchart Acked-by: Paul Mundt Acked-by: Linus Walleij Signed-off-by: Simon Horman --- include/linux/sh_pfc.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'include/linux') diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index c19a0925829a..58587f94d67a 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h @@ -94,7 +94,7 @@ struct pfc_window { unsigned long size; }; -struct sh_pfc { +struct sh_pfc_platform_data { char *name; pinmux_enum_t reserved_id; struct pinmux_range data; @@ -117,17 +117,21 @@ struct sh_pfc { struct pinmux_irq *gpio_irq; unsigned int gpio_irq_size; - spinlock_t lock; - struct resource *resource; unsigned int num_resources; - struct pfc_window *window; unsigned long unlock_reg; }; +struct sh_pfc { + struct sh_pfc_platform_data *pdata; + spinlock_t lock; + + struct pfc_window *window; +}; + /* XXX compat for now */ -#define pinmux_info sh_pfc +#define pinmux_info sh_pfc_platform_data /* drivers/sh/pfc/gpio.c */ int sh_pfc_register_gpiochip(struct sh_pfc *pfc); @@ -136,7 +140,7 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc); int sh_pfc_register_pinctrl(struct sh_pfc *pfc); /* drivers/sh/pfc/core.c */ -int register_sh_pfc(struct sh_pfc *pfc); +int register_sh_pfc(struct sh_pfc_platform_data *pfc); int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos); void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, @@ -151,8 +155,8 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, /* xxx */ static inline int register_pinmux(struct pinmux_info *pip) { - struct sh_pfc *pfc = pip; - return register_sh_pfc(pfc); + struct sh_pfc_platform_data *pdata = pip; + return register_sh_pfc(pdata); } enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; -- cgit v1.2.3-59-g8ed1b From f9165132c5ee681235068857e4f86c7ecc5a4617 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Dec 2012 23:50:44 +0100 Subject: sh-pfc: Move private definitions and declarations to private header Move all private structure definitions and function declarations from include/linux/sh_pfc.h to drivers/sh/pfc/core.h. Signed-off-by: Laurent Pinchart Acked-by: Paul Mundt Acked-by: Linus Walleij Signed-off-by: Simon Horman --- drivers/sh/pfc/core.c | 2 ++ drivers/sh/pfc/core.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ drivers/sh/pfc/gpio.c | 2 ++ drivers/sh/pfc/pinctrl.c | 2 ++ include/linux/sh_pfc.h | 29 ----------------------------- 5 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 drivers/sh/pfc/core.h (limited to 'include/linux') diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c index ecbe51d9f563..72421a4a883d 100644 --- a/drivers/sh/pfc/core.c +++ b/drivers/sh/pfc/core.c @@ -21,6 +21,8 @@ #include #include +#include "core.h" + static struct sh_pfc sh_pfc __read_mostly; static void pfc_iounmap(struct sh_pfc *pfc) diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h new file mode 100644 index 000000000000..b07ae259c0eb --- /dev/null +++ b/drivers/sh/pfc/core.h @@ -0,0 +1,44 @@ +/* + * SuperH Pin Function Controller support. + * + * Copyright (C) 2012 Renesas Solutions Corp. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ +#ifndef __SH_PFC_CORE_H__ +#define __SH_PFC_CORE_H__ + +#include +#include +#include + +struct pfc_window { + phys_addr_t phys; + void __iomem *virt; + unsigned long size; +}; + +struct sh_pfc { + struct sh_pfc_platform_data *pdata; + spinlock_t lock; + + struct pfc_window *window; +}; + +int sh_pfc_register_gpiochip(struct sh_pfc *pfc); + +int sh_pfc_register_pinctrl(struct sh_pfc *pfc); + +int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos); +void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, + unsigned long value); +int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, + struct pinmux_data_reg **drp, int *bitp); +int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, + pinmux_enum_t *enum_idp); +int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, + int cfg_mode); + +#endif /* __SH_PFC_CORE_H__ */ diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c index 7597a024fac8..565b366c909f 100644 --- a/drivers/sh/pfc/gpio.c +++ b/drivers/sh/pfc/gpio.c @@ -19,6 +19,8 @@ #include #include +#include "core.h" + struct sh_pfc_chip { struct sh_pfc *pfc; struct gpio_chip gpio_chip; diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c index 3a2c77d3248f..5801a5686148 100644 --- a/drivers/sh/pfc/pinctrl.c +++ b/drivers/sh/pfc/pinctrl.c @@ -24,6 +24,8 @@ #include #include +#include "core.h" + struct sh_pfc_pinctrl { struct pinctrl_dev *pctl; struct sh_pfc *pfc; diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index 58587f94d67a..f7f01b231b66 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h @@ -88,12 +88,6 @@ struct pinmux_range { pinmux_enum_t force; }; -struct pfc_window { - phys_addr_t phys; - void __iomem *virt; - unsigned long size; -}; - struct sh_pfc_platform_data { char *name; pinmux_enum_t reserved_id; @@ -123,35 +117,12 @@ struct sh_pfc_platform_data { unsigned long unlock_reg; }; -struct sh_pfc { - struct sh_pfc_platform_data *pdata; - spinlock_t lock; - - struct pfc_window *window; -}; - /* XXX compat for now */ #define pinmux_info sh_pfc_platform_data -/* drivers/sh/pfc/gpio.c */ -int sh_pfc_register_gpiochip(struct sh_pfc *pfc); - -/* drivers/sh/pfc/pinctrl.c */ -int sh_pfc_register_pinctrl(struct sh_pfc *pfc); - /* drivers/sh/pfc/core.c */ int register_sh_pfc(struct sh_pfc_platform_data *pfc); -int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos); -void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos, - unsigned long value); -int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, - struct pinmux_data_reg **drp, int *bitp); -int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, - pinmux_enum_t *enum_idp); -int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, - int cfg_mode); - /* xxx */ static inline int register_pinmux(struct pinmux_info *pip) { -- cgit v1.2.3-59-g8ed1b From 8682b3c522c639f3a0de31c86bb91f2f9a6c76cb Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Dec 2012 23:51:17 +0100 Subject: sh-pfc: Remove platform device registration The PFC platform device is now registered by arch code, remove the legacy registration mechanism. Signed-off-by: Laurent Pinchart Acked-by: Paul Mundt Acked-by: Linus Walleij Signed-off-by: Simon Horman --- drivers/sh/pfc/core.c | 12 ------------ include/linux/sh_pfc.h | 10 ---------- 2 files changed, 22 deletions(-) (limited to 'include/linux') diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c index b2e121d927a0..9456c70a2da7 100644 --- a/drivers/sh/pfc/core.c +++ b/drivers/sh/pfc/core.c @@ -578,18 +578,6 @@ static struct platform_driver sh_pfc_driver = { }, }; -static struct platform_device sh_pfc_device = { - .name = DRV_NAME, - .id = -1, -}; - -int __init register_sh_pfc(struct sh_pfc_platform_data *pdata) -{ - sh_pfc_device.dev.platform_data = pdata; - - return platform_device_register(&sh_pfc_device); -} - static int __init sh_pfc_init(void) { return platform_driver_register(&sh_pfc_driver); diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index f7f01b231b66..fa1fec084229 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h @@ -120,16 +120,6 @@ struct sh_pfc_platform_data { /* XXX compat for now */ #define pinmux_info sh_pfc_platform_data -/* drivers/sh/pfc/core.c */ -int register_sh_pfc(struct sh_pfc_platform_data *pfc); - -/* xxx */ -static inline int register_pinmux(struct pinmux_info *pip) -{ - struct sh_pfc_platform_data *pdata = pip; - return register_sh_pfc(pdata); -} - enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; /* helper macro for port */ -- cgit v1.2.3-59-g8ed1b From 56dc04af3b5e54be330e18630301d2bda5d365eb Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Dec 2012 23:51:18 +0100 Subject: sh-pfc: Remove unused resource and num_resources platform data fields The fields are now unused, remove them. Signed-off-by: Laurent Pinchart Acked-by: Paul Mundt Acked-by: Linus Walleij Signed-off-by: Simon Horman --- drivers/sh/pfc/core.c | 17 ++++------------- include/linux/sh_pfc.h | 3 --- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'include/linux') diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c index 9456c70a2da7..8e7818bccb29 100644 --- a/drivers/sh/pfc/core.c +++ b/drivers/sh/pfc/core.c @@ -28,31 +28,22 @@ static int sh_pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev) { - unsigned int num_resources; struct resource *res; int k; - if (pdev->num_resources) { - num_resources = pdev->num_resources; - res = pdev->resource; - } else { - num_resources = pfc->pdata->num_resources; - res = pfc->pdata->resource; - } - - if (num_resources == 0) { + if (pdev->num_resources == 0) { pfc->num_windows = 0; return 0; } - pfc->window = devm_kzalloc(pfc->dev, num_resources * + pfc->window = devm_kzalloc(pfc->dev, pdev->num_resources * sizeof(*pfc->window), GFP_NOWAIT); if (!pfc->window) return -ENOMEM; - pfc->num_windows = num_resources; + pfc->num_windows = pdev->num_resources; - for (k = 0; k < num_resources; k++, res++) { + for (k = 0, res = pdev->resource; k < pdev->num_resources; k++, res++) { WARN_ON(resource_type(res) != IORESOURCE_MEM); pfc->window[k].phys = res->start; pfc->window[k].size = resource_size(res); diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index fa1fec084229..4f942337d77e 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h @@ -111,9 +111,6 @@ struct sh_pfc_platform_data { struct pinmux_irq *gpio_irq; unsigned int gpio_irq_size; - struct resource *resource; - unsigned int num_resources; - unsigned long unlock_reg; }; -- cgit v1.2.3-59-g8ed1b From 19bb7fe36950ff74ce322cc29f6f4e025999f1f0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Dec 2012 23:51:20 +0100 Subject: sh-pfc: Support pinmux info in driver data instead of platform data Pinmux information should be provided by the pinmux driver, not arch code. Make it possible to do so by supporting pinmux information passed through the driver_data field in the platform ID table. Platform data will remain supported until all arch code has been converted. Rename the sh_pfc_platform_data structure to sh_pfc_soc_info to reflect this. Signed-off-by: Laurent Pinchart Acked-by: Paul Mundt Acked-by: Linus Walleij Signed-off-by: Simon Horman --- drivers/pinctrl/sh-pfc/core.c | 52 +++++++++++++++++++++------------------- drivers/pinctrl/sh-pfc/core.h | 2 +- drivers/pinctrl/sh-pfc/gpio.c | 18 +++++++------- drivers/pinctrl/sh-pfc/pinctrl.c | 28 +++++++++++----------- include/linux/sh_pfc.h | 4 ++-- 5 files changed, 53 insertions(+), 51 deletions(-) (limited to 'include/linux') diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index 8e7818bccb29..95cd10f83e18 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c @@ -213,9 +213,9 @@ static void sh_pfc_write_config_reg(struct sh_pfc *pfc, data &= mask; data |= value; - if (pfc->pdata->unlock_reg) + if (pfc->info->unlock_reg) sh_pfc_write_raw_reg( - sh_pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg), 32, + sh_pfc_phys_to_virt(pfc, pfc->info->unlock_reg), 32, ~data); sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data); @@ -223,16 +223,16 @@ static void sh_pfc_write_config_reg(struct sh_pfc *pfc, static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned gpio) { - struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; + struct pinmux_gpio *gpiop = &pfc->info->gpios[gpio]; struct pinmux_data_reg *data_reg; int k, n; - if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data)) + if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->info->data)) return -1; k = 0; while (1) { - data_reg = pfc->pdata->data_regs + k; + data_reg = pfc->info->data_regs + k; if (!data_reg->reg_width) break; @@ -261,12 +261,12 @@ static void sh_pfc_setup_data_regs(struct sh_pfc *pfc) struct pinmux_data_reg *drp; int k; - for (k = pfc->pdata->first_gpio; k <= pfc->pdata->last_gpio; k++) + for (k = pfc->info->first_gpio; k <= pfc->info->last_gpio; k++) sh_pfc_setup_data_reg(pfc, k); k = 0; while (1) { - drp = pfc->pdata->data_regs + k; + drp = pfc->info->data_regs + k; if (!drp->reg_width) break; @@ -280,15 +280,15 @@ static void sh_pfc_setup_data_regs(struct sh_pfc *pfc) int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio, struct pinmux_data_reg **drp, int *bitp) { - struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio]; + struct pinmux_gpio *gpiop = &pfc->info->gpios[gpio]; int k, n; - if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data)) + if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->info->data)) return -1; k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT; n = (gpiop->flags & PINMUX_FLAG_DBIT) >> PINMUX_FLAG_DBIT_SHIFT; - *drp = pfc->pdata->data_regs + k; + *drp = pfc->info->data_regs + k; *bitp = n; return 0; } @@ -303,7 +303,7 @@ static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id, k = 0; while (1) { - config_reg = pfc->pdata->cfg_regs + k; + config_reg = pfc->info->cfg_regs + k; r_width = config_reg->reg_width; f_width = config_reg->field_width; @@ -341,12 +341,12 @@ static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id, int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, pinmux_enum_t *enum_idp) { - pinmux_enum_t enum_id = pfc->pdata->gpios[gpio].enum_id; - pinmux_enum_t *data = pfc->pdata->gpio_data; + pinmux_enum_t enum_id = pfc->info->gpios[gpio].enum_id; + pinmux_enum_t *data = pfc->info->gpio_data; int k; - if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->data)) { - if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->mark)) { + if (!sh_pfc_enum_in_range(enum_id, &pfc->info->data)) { + if (!sh_pfc_enum_in_range(enum_id, &pfc->info->mark)) { pr_err("non data/mark enum_id for gpio %d\n", gpio); return -1; } @@ -357,7 +357,7 @@ int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos, return pos + 1; } - for (k = 0; k < pfc->pdata->gpio_data_size; k++) { + for (k = 0; k < pfc->info->gpio_data_size; k++) { if (data[k] == enum_id) { *enum_idp = data[k + 1]; return k + 1; @@ -384,19 +384,19 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, break; case PINMUX_TYPE_OUTPUT: - range = &pfc->pdata->output; + range = &pfc->info->output; break; case PINMUX_TYPE_INPUT: - range = &pfc->pdata->input; + range = &pfc->info->input; break; case PINMUX_TYPE_INPUT_PULLUP: - range = &pfc->pdata->input_pu; + range = &pfc->info->input_pu; break; case PINMUX_TYPE_INPUT_PULLDOWN: - range = &pfc->pdata->input_pd; + range = &pfc->info->input_pd; break; default: @@ -416,7 +416,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, break; /* first check if this is a function enum */ - in_range = sh_pfc_enum_in_range(enum_id, &pfc->pdata->function); + in_range = sh_pfc_enum_in_range(enum_id, &pfc->info->function); if (!in_range) { /* not a function enum */ if (range) { @@ -482,7 +482,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type, static int sh_pfc_probe(struct platform_device *pdev) { - struct sh_pfc_platform_data *pdata = pdev->dev.platform_data; + struct sh_pfc_soc_info *info; struct sh_pfc *pfc; int ret; @@ -491,14 +491,16 @@ static int sh_pfc_probe(struct platform_device *pdev) */ BUILD_BUG_ON(PINMUX_FLAG_TYPE > ((1 << PINMUX_FLAG_DBIT_SHIFT) - 1)); - if (pdata == NULL) + info = pdev->id_entry->driver_data + ? (void *)pdev->id_entry->driver_data : pdev->dev.platform_data; + if (info == NULL) return -ENODEV; pfc = devm_kzalloc(&pdev->dev, sizeof(pfc), GFP_KERNEL); if (pfc == NULL) return -ENOMEM; - pfc->pdata = pdata; + pfc->info = info; pfc->dev = &pdev->dev; ret = sh_pfc_ioremap(pfc, pdev); @@ -534,7 +536,7 @@ static int sh_pfc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pfc); - pr_info("%s support registered\n", pdata->name); + pr_info("%s support registered\n", info->name); return 0; } diff --git a/drivers/pinctrl/sh-pfc/core.h b/drivers/pinctrl/sh-pfc/core.h index 87ae5fd2a201..2c82e9df6f8a 100644 --- a/drivers/pinctrl/sh-pfc/core.h +++ b/drivers/pinctrl/sh-pfc/core.h @@ -25,7 +25,7 @@ struct sh_pfc_pinctrl; struct sh_pfc { struct device *dev; - struct sh_pfc_platform_data *pdata; + struct sh_pfc_soc_info *info; spinlock_t lock; unsigned int num_windows; diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index a0454f321710..3cbdfea1dec0 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c @@ -106,11 +106,11 @@ static int sh_gpio_to_irq(struct gpio_chip *gc, unsigned offset) if (pos <= 0 || !enum_id) break; - for (i = 0; i < pfc->pdata->gpio_irq_size; i++) { - enum_ids = pfc->pdata->gpio_irq[i].enum_ids; + for (i = 0; i < pfc->info->gpio_irq_size; i++) { + enum_ids = pfc->info->gpio_irq[i].enum_ids; for (k = 0; enum_ids[k]; k++) { if (enum_ids[k] == enum_id) - return pfc->pdata->gpio_irq[i].irq; + return pfc->info->gpio_irq[i].irq; } } } @@ -131,12 +131,12 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip) gc->set = sh_gpio_set; gc->to_irq = sh_gpio_to_irq; - WARN_ON(pfc->pdata->first_gpio != 0); /* needs testing */ + WARN_ON(pfc->info->first_gpio != 0); /* needs testing */ - gc->label = pfc->pdata->name; + gc->label = pfc->info->name; gc->owner = THIS_MODULE; - gc->base = pfc->pdata->first_gpio; - gc->ngpio = (pfc->pdata->last_gpio - pfc->pdata->first_gpio) + 1; + gc->base = pfc->info->first_gpio; + gc->ngpio = (pfc->info->last_gpio - pfc->info->first_gpio) + 1; } int sh_pfc_register_gpiochip(struct sh_pfc *pfc) @@ -159,8 +159,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc) pfc->gpio = chip; pr_info("%s handling gpio %d -> %d\n", - pfc->pdata->name, pfc->pdata->first_gpio, - pfc->pdata->last_gpio); + pfc->info->name, pfc->info->first_gpio, + pfc->info->last_gpio); return 0; } diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 221bde03913a..fdfe7bea1502 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c @@ -140,7 +140,7 @@ static int sh_pfc_reconfig_pin(struct sh_pfc *pfc, unsigned offset, spin_lock_irqsave(&pfc->lock, flags); - pinmux_type = pfc->pdata->gpios[offset].flags & PINMUX_FLAG_TYPE; + pinmux_type = pfc->info->gpios[offset].flags & PINMUX_FLAG_TYPE; /* * See if the present config needs to first be de-configured. @@ -172,8 +172,8 @@ static int sh_pfc_reconfig_pin(struct sh_pfc *pfc, unsigned offset, GPIO_CFG_REQ) != 0) goto err; - pfc->pdata->gpios[offset].flags &= ~PINMUX_FLAG_TYPE; - pfc->pdata->gpios[offset].flags |= new_type; + pfc->info->gpios[offset].flags &= ~PINMUX_FLAG_TYPE; + pfc->info->gpios[offset].flags |= new_type; ret = 0; @@ -195,7 +195,7 @@ static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev, spin_lock_irqsave(&pfc->lock, flags); - pinmux_type = pfc->pdata->gpios[offset].flags & PINMUX_FLAG_TYPE; + pinmux_type = pfc->info->gpios[offset].flags & PINMUX_FLAG_TYPE; switch (pinmux_type) { case PINMUX_TYPE_FUNCTION: @@ -236,7 +236,7 @@ static void sh_pfc_gpio_disable_free(struct pinctrl_dev *pctldev, spin_lock_irqsave(&pfc->lock, flags); - pinmux_type = pfc->pdata->gpios[offset].flags & PINMUX_FLAG_TYPE; + pinmux_type = pfc->info->gpios[offset].flags & PINMUX_FLAG_TYPE; sh_pfc_config_gpio(pfc, offset, pinmux_type, GPIO_CFG_FREE); @@ -270,7 +270,7 @@ static int sh_pfc_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin, struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); struct sh_pfc *pfc = pmx->pfc; - *config = pfc->pdata->gpios[pin].flags & PINMUX_FLAG_TYPE; + *config = pfc->info->gpios[pin].flags & PINMUX_FLAG_TYPE; return 0; } @@ -354,7 +354,7 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx) unsigned long flags; int i; - pmx->nr_pads = pfc->pdata->last_gpio - pfc->pdata->first_gpio + 1; + pmx->nr_pads = pfc->info->last_gpio - pfc->info->first_gpio + 1; pmx->pads = devm_kzalloc(pfc->dev, sizeof(*pmx->pads) * pmx->nr_pads, GFP_KERNEL); @@ -373,9 +373,9 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx) */ for (i = 0; i < pmx->nr_pads; i++) { struct pinctrl_pin_desc *pin = pmx->pads + i; - struct pinmux_gpio *gpio = pfc->pdata->gpios + i; + struct pinmux_gpio *gpio = pfc->info->gpios + i; - pin->number = pfc->pdata->first_gpio + i; + pin->number = pfc->info->first_gpio + i; pin->name = gpio->name; /* XXX */ @@ -406,7 +406,7 @@ static int sh_pfc_map_functions(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx) spin_lock_irqsave(&pmx->lock, flags); for (i = fn = 0; i < pmx->nr_pads; i++) { - struct pinmux_gpio *gpio = pfc->pdata->gpios + i; + struct pinmux_gpio *gpio = pfc->info->gpios + i; if ((gpio->flags & PINMUX_FLAG_TYPE) == PINMUX_TYPE_FUNCTION) pmx->functions[fn++] = gpio; @@ -443,10 +443,10 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc) if (IS_ERR(pmx->pctl)) return PTR_ERR(pmx->pctl); - sh_pfc_gpio_range.npins = pfc->pdata->last_gpio - - pfc->pdata->first_gpio + 1; - sh_pfc_gpio_range.base = pfc->pdata->first_gpio; - sh_pfc_gpio_range.pin_base = pfc->pdata->first_gpio; + sh_pfc_gpio_range.npins = pfc->info->last_gpio + - pfc->info->first_gpio + 1; + sh_pfc_gpio_range.base = pfc->info->first_gpio; + sh_pfc_gpio_range.pin_base = pfc->info->first_gpio; pinctrl_add_gpio_range(pmx->pctl, &sh_pfc_gpio_range); diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index 4f942337d77e..9fd62282c625 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h @@ -88,7 +88,7 @@ struct pinmux_range { pinmux_enum_t force; }; -struct sh_pfc_platform_data { +struct sh_pfc_soc_info { char *name; pinmux_enum_t reserved_id; struct pinmux_range data; @@ -115,7 +115,7 @@ struct sh_pfc_platform_data { }; /* XXX compat for now */ -#define pinmux_info sh_pfc_platform_data +#define pinmux_info sh_pfc_soc_info enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; -- cgit v1.2.3-59-g8ed1b From b93911e3d59bcd665a810fdf8ec7040a74eb4ff4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Dec 2012 23:51:54 +0100 Subject: sh-pfc: Remove pinmux_info definition The pinmux_info alias to sh_pfc_soc_info isn't needed anymore, remove it. Signed-off-by: Laurent Pinchart Acked-by: Paul Mundt Acked-by: Linus Walleij Signed-off-by: Simon Horman --- include/linux/sh_pfc.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h index 9fd62282c625..13049c4c8d30 100644 --- a/include/linux/sh_pfc.h +++ b/include/linux/sh_pfc.h @@ -114,9 +114,6 @@ struct sh_pfc_soc_info { unsigned long unlock_reg; }; -/* XXX compat for now */ -#define pinmux_info sh_pfc_soc_info - enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; /* helper macro for port */ -- cgit v1.2.3-59-g8ed1b From c3323806a67c0c656e27956b7340e37ba6c6968b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Dec 2012 23:51:55 +0100 Subject: sh-pfc: Move sh_pfc.h from include/linux/ to driver directory The header file isn't used by arch code anymore. Make it private to the driver. Signed-off-by: Laurent Pinchart Acked-by: Paul Mundt Acked-by: Linus Walleij Signed-off-by: Simon Horman --- drivers/pinctrl/sh-pfc/core.c | 1 - drivers/pinctrl/sh-pfc/core.h | 3 +- drivers/pinctrl/sh-pfc/gpio.c | 1 - drivers/pinctrl/sh-pfc/pfc-r8a7740.c | 3 +- drivers/pinctrl/sh-pfc/pfc-r8a7779.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7203.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7264.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7269.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7372.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh73a0.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7720.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7722.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7723.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7724.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7734.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7757.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7785.c | 3 +- drivers/pinctrl/sh-pfc/pfc-sh7786.c | 3 +- drivers/pinctrl/sh-pfc/pfc-shx3.c | 3 +- drivers/pinctrl/sh-pfc/pinctrl.c | 1 - drivers/pinctrl/sh-pfc/sh_pfc.h | 195 +++++++++++++++++++++++++++++++++++ include/linux/sh_pfc.h | 195 ----------------------------------- 22 files changed, 229 insertions(+), 215 deletions(-) create mode 100644 drivers/pinctrl/sh-pfc/sh_pfc.h delete mode 100644 include/linux/sh_pfc.h (limited to 'include/linux') diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index 33181f4b0731..d323c24fffaf 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "core.h" diff --git a/drivers/pinctrl/sh-pfc/core.h b/drivers/pinctrl/sh-pfc/core.h index 804082678a5c..ba7c33c33599 100644 --- a/drivers/pinctrl/sh-pfc/core.h +++ b/drivers/pinctrl/sh-pfc/core.h @@ -11,9 +11,10 @@ #define __SH_PFC_CORE_H__ #include -#include #include +#include "sh_pfc.h" + struct sh_pfc_window { phys_addr_t phys; void __iomem *virt; diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index 3cbdfea1dec0..a535075c8b69 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c index 0ab4cb6dc09b..214788c4a606 100644 --- a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include #include #include +#include "sh_pfc.h" + #define CPU_ALL_PORT(fn, pfx, sfx) \ PORT_10(fn, pfx, sfx), PORT_90(fn, pfx, sfx), \ PORT_10(fn, pfx##10, sfx), PORT_90(fn, pfx##1, sfx), \ diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7779.c b/drivers/pinctrl/sh-pfc/pfc-r8a7779.c index 81471722682f..13feaa0c0eb7 100644 --- a/drivers/pinctrl/sh-pfc/pfc-r8a7779.c +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7779.c @@ -19,9 +19,10 @@ */ #include -#include #include +#include "sh_pfc.h" + #define CPU_32_PORT(fn, pfx, sfx) \ PORT_10(fn, pfx, sfx), PORT_10(fn, pfx##1, sfx), \ PORT_10(fn, pfx##2, sfx), PORT_1(fn, pfx##30, sfx), \ diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7203.c b/drivers/pinctrl/sh-pfc/pfc-sh7203.c index 62bd17329d29..01b425dfd162 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7203.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7203.c @@ -10,9 +10,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7264.c b/drivers/pinctrl/sh-pfc/pfc-sh7264.c index 03d3f9c51373..2ba5639dcf34 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7264.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7264.c @@ -10,9 +10,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7269.c b/drivers/pinctrl/sh-pfc/pfc-sh7269.c index dab04d45644f..b1b5d6d4ad76 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7269.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7269.c @@ -11,9 +11,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7372.c b/drivers/pinctrl/sh-pfc/pfc-sh7372.c index a52fabe90f38..d44e7f02069b 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7372.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7372.c @@ -21,10 +21,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include #include #include +#include "sh_pfc.h" + #define CPU_ALL_PORT(fn, pfx, sfx) \ PORT_10(fn, pfx, sfx), PORT_90(fn, pfx, sfx), \ PORT_10(fn, pfx##10, sfx), PORT_10(fn, pfx##11, sfx), \ diff --git a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c index 8a0eee95e025..709008e94124 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include #include #include +#include "sh_pfc.h" + #define CPU_ALL_PORT(fn, pfx, sfx) \ PORT_10(fn, pfx, sfx), PORT_10(fn, pfx##1, sfx), \ PORT_10(fn, pfx##2, sfx), PORT_10(fn, pfx##3, sfx), \ diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7720.c b/drivers/pinctrl/sh-pfc/pfc-sh7720.c index 20d05776d124..10872ed688a6 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7720.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7720.c @@ -10,9 +10,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7722.c b/drivers/pinctrl/sh-pfc/pfc-sh7722.c index f58f00948454..2de0929315e6 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7722.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7722.c @@ -1,9 +1,10 @@ #include #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7723.c b/drivers/pinctrl/sh-pfc/pfc-sh7723.c index fa3d36bba192..609673d3d70e 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7723.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7723.c @@ -10,9 +10,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7724.c b/drivers/pinctrl/sh-pfc/pfc-sh7724.c index 7ad72c20209d..233fbf750b39 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7724.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7724.c @@ -15,9 +15,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7734.c b/drivers/pinctrl/sh-pfc/pfc-sh7734.c index cbb5f4c5f4b0..23d76d262c32 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7734.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7734.c @@ -10,9 +10,10 @@ */ #include #include -#include #include +#include "sh_pfc.h" + #define CPU_32_PORT(fn, pfx, sfx) \ PORT_10(fn, pfx, sfx), PORT_10(fn, pfx##1, sfx), \ PORT_10(fn, pfx##2, sfx), PORT_1(fn, pfx##30, sfx), \ diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7757.c b/drivers/pinctrl/sh-pfc/pfc-sh7757.c index 6f707a0dffee..5ed74cd0ba99 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7757.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7757.c @@ -15,9 +15,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7785.c b/drivers/pinctrl/sh-pfc/pfc-sh7785.c index 23f2c316412c..3b1825d925bb 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7785.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7785.c @@ -10,9 +10,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7786.c b/drivers/pinctrl/sh-pfc/pfc-sh7786.c index e1453cf7ed22..1e18b58f9e5f 100644 --- a/drivers/pinctrl/sh-pfc/pfc-sh7786.c +++ b/drivers/pinctrl/sh-pfc/pfc-sh7786.c @@ -15,9 +15,10 @@ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pfc-shx3.c b/drivers/pinctrl/sh-pfc/pfc-shx3.c index bd54042a1066..ccf6918b03c6 100644 --- a/drivers/pinctrl/sh-pfc/pfc-shx3.c +++ b/drivers/pinctrl/sh-pfc/pfc-shx3.c @@ -9,9 +9,10 @@ */ #include #include -#include #include +#include "sh_pfc.h" + enum { PINMUX_RESERVED = 0, diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index fdfe7bea1502..11e0e1374d65 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h new file mode 100644 index 000000000000..13049c4c8d30 --- /dev/null +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h @@ -0,0 +1,195 @@ +/* + * SuperH Pin Function Controller Support + * + * Copyright (c) 2008 Magnus Damm + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + +#ifndef __SH_PFC_H +#define __SH_PFC_H + +#include +#include + +typedef unsigned short pinmux_enum_t; +typedef unsigned short pinmux_flag_t; + +enum { + PINMUX_TYPE_NONE, + + PINMUX_TYPE_FUNCTION, + PINMUX_TYPE_GPIO, + PINMUX_TYPE_OUTPUT, + PINMUX_TYPE_INPUT, + PINMUX_TYPE_INPUT_PULLUP, + PINMUX_TYPE_INPUT_PULLDOWN, + + PINMUX_FLAG_TYPE, /* must be last */ +}; + +#define PINMUX_FLAG_DBIT_SHIFT 5 +#define PINMUX_FLAG_DBIT (0x1f << PINMUX_FLAG_DBIT_SHIFT) +#define PINMUX_FLAG_DREG_SHIFT 10 +#define PINMUX_FLAG_DREG (0x3f << PINMUX_FLAG_DREG_SHIFT) + +struct pinmux_gpio { + pinmux_enum_t enum_id; + pinmux_flag_t flags; + const char *name; +}; + +#define PINMUX_GPIO(gpio, data_or_mark) \ + [gpio] = { .name = __stringify(gpio), .enum_id = data_or_mark, .flags = PINMUX_TYPE_NONE } + +#define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0 + +struct pinmux_cfg_reg { + unsigned long reg, reg_width, field_width; + unsigned long *cnt; + pinmux_enum_t *enum_ids; + unsigned long *var_field_width; +}; + +#define PINMUX_CFG_REG(name, r, r_width, f_width) \ + .reg = r, .reg_width = r_width, .field_width = f_width, \ + .cnt = (unsigned long [r_width / f_width]) {}, \ + .enum_ids = (pinmux_enum_t [(r_width / f_width) * (1 << f_width)]) + +#define PINMUX_CFG_REG_VAR(name, r, r_width, var_fw0, var_fwn...) \ + .reg = r, .reg_width = r_width, \ + .cnt = (unsigned long [r_width]) {}, \ + .var_field_width = (unsigned long [r_width]) { var_fw0, var_fwn, 0 }, \ + .enum_ids = (pinmux_enum_t []) + +struct pinmux_data_reg { + unsigned long reg, reg_width, reg_shadow; + pinmux_enum_t *enum_ids; + void __iomem *mapped_reg; +}; + +#define PINMUX_DATA_REG(name, r, r_width) \ + .reg = r, .reg_width = r_width, \ + .enum_ids = (pinmux_enum_t [r_width]) \ + +struct pinmux_irq { + int irq; + pinmux_enum_t *enum_ids; +}; + +#define PINMUX_IRQ(irq_nr, ids...) \ + { .irq = irq_nr, .enum_ids = (pinmux_enum_t []) { ids, 0 } } \ + +struct pinmux_range { + pinmux_enum_t begin; + pinmux_enum_t end; + pinmux_enum_t force; +}; + +struct sh_pfc_soc_info { + char *name; + pinmux_enum_t reserved_id; + struct pinmux_range data; + struct pinmux_range input; + struct pinmux_range input_pd; + struct pinmux_range input_pu; + struct pinmux_range output; + struct pinmux_range mark; + struct pinmux_range function; + + unsigned first_gpio, last_gpio; + + struct pinmux_gpio *gpios; + struct pinmux_cfg_reg *cfg_regs; + struct pinmux_data_reg *data_regs; + + pinmux_enum_t *gpio_data; + unsigned int gpio_data_size; + + struct pinmux_irq *gpio_irq; + unsigned int gpio_irq_size; + + unsigned long unlock_reg; +}; + +enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; + +/* helper macro for port */ +#define PORT_1(fn, pfx, sfx) fn(pfx, sfx) + +#define PORT_10(fn, pfx, sfx) \ + PORT_1(fn, pfx##0, sfx), PORT_1(fn, pfx##1, sfx), \ + PORT_1(fn, pfx##2, sfx), PORT_1(fn, pfx##3, sfx), \ + PORT_1(fn, pfx##4, sfx), PORT_1(fn, pfx##5, sfx), \ + PORT_1(fn, pfx##6, sfx), PORT_1(fn, pfx##7, sfx), \ + PORT_1(fn, pfx##8, sfx), PORT_1(fn, pfx##9, sfx) + +#define PORT_90(fn, pfx, sfx) \ + PORT_10(fn, pfx##1, sfx), PORT_10(fn, pfx##2, sfx), \ + PORT_10(fn, pfx##3, sfx), PORT_10(fn, pfx##4, sfx), \ + PORT_10(fn, pfx##5, sfx), PORT_10(fn, pfx##6, sfx), \ + PORT_10(fn, pfx##7, sfx), PORT_10(fn, pfx##8, sfx), \ + PORT_10(fn, pfx##9, sfx) + +#define _PORT_ALL(pfx, sfx) pfx##_##sfx +#define _GPIO_PORT(pfx, sfx) PINMUX_GPIO(GPIO_PORT##pfx, PORT##pfx##_DATA) +#define PORT_ALL(str) CPU_ALL_PORT(_PORT_ALL, PORT, str) +#define GPIO_PORT_ALL() CPU_ALL_PORT(_GPIO_PORT, , unused) +#define GPIO_FN(str) PINMUX_GPIO(GPIO_FN_##str, str##_MARK) + +/* helper macro for pinmux_enum_t */ +#define PORT_DATA_I(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_IN) + +#define PORT_DATA_I_PD(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, \ + PORT##nr##_IN, PORT##nr##_IN_PD) + +#define PORT_DATA_I_PU(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, \ + PORT##nr##_IN, PORT##nr##_IN_PU) + +#define PORT_DATA_I_PU_PD(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, \ + PORT##nr##_IN, PORT##nr##_IN_PD, PORT##nr##_IN_PU) + +#define PORT_DATA_O(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT) + +#define PORT_DATA_IO(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ + PORT##nr##_IN) + +#define PORT_DATA_IO_PD(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ + PORT##nr##_IN, PORT##nr##_IN_PD) + +#define PORT_DATA_IO_PU(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ + PORT##nr##_IN, PORT##nr##_IN_PU) + +#define PORT_DATA_IO_PU_PD(nr) \ + PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ + PORT##nr##_IN, PORT##nr##_IN_PD, PORT##nr##_IN_PU) + +/* helper macro for top 4 bits in PORTnCR */ +#define _PCRH(in, in_pd, in_pu, out) \ + 0, (out), (in), 0, \ + 0, 0, 0, 0, \ + 0, 0, (in_pd), 0, \ + 0, 0, (in_pu), 0 + +#define PORTCR(nr, reg) \ + { \ + PINMUX_CFG_REG("PORT" nr "CR", reg, 8, 4) { \ + _PCRH(PORT##nr##_IN, PORT##nr##_IN_PD, \ + PORT##nr##_IN_PU, PORT##nr##_OUT), \ + PORT##nr##_FN0, PORT##nr##_FN1, \ + PORT##nr##_FN2, PORT##nr##_FN3, \ + PORT##nr##_FN4, PORT##nr##_FN5, \ + PORT##nr##_FN6, PORT##nr##_FN7 } \ + } + +#endif /* __SH_PFC_H */ diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h deleted file mode 100644 index 13049c4c8d30..000000000000 --- a/include/linux/sh_pfc.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * SuperH Pin Function Controller Support - * - * Copyright (c) 2008 Magnus Damm - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - */ - -#ifndef __SH_PFC_H -#define __SH_PFC_H - -#include -#include - -typedef unsigned short pinmux_enum_t; -typedef unsigned short pinmux_flag_t; - -enum { - PINMUX_TYPE_NONE, - - PINMUX_TYPE_FUNCTION, - PINMUX_TYPE_GPIO, - PINMUX_TYPE_OUTPUT, - PINMUX_TYPE_INPUT, - PINMUX_TYPE_INPUT_PULLUP, - PINMUX_TYPE_INPUT_PULLDOWN, - - PINMUX_FLAG_TYPE, /* must be last */ -}; - -#define PINMUX_FLAG_DBIT_SHIFT 5 -#define PINMUX_FLAG_DBIT (0x1f << PINMUX_FLAG_DBIT_SHIFT) -#define PINMUX_FLAG_DREG_SHIFT 10 -#define PINMUX_FLAG_DREG (0x3f << PINMUX_FLAG_DREG_SHIFT) - -struct pinmux_gpio { - pinmux_enum_t enum_id; - pinmux_flag_t flags; - const char *name; -}; - -#define PINMUX_GPIO(gpio, data_or_mark) \ - [gpio] = { .name = __stringify(gpio), .enum_id = data_or_mark, .flags = PINMUX_TYPE_NONE } - -#define PINMUX_DATA(data_or_mark, ids...) data_or_mark, ids, 0 - -struct pinmux_cfg_reg { - unsigned long reg, reg_width, field_width; - unsigned long *cnt; - pinmux_enum_t *enum_ids; - unsigned long *var_field_width; -}; - -#define PINMUX_CFG_REG(name, r, r_width, f_width) \ - .reg = r, .reg_width = r_width, .field_width = f_width, \ - .cnt = (unsigned long [r_width / f_width]) {}, \ - .enum_ids = (pinmux_enum_t [(r_width / f_width) * (1 << f_width)]) - -#define PINMUX_CFG_REG_VAR(name, r, r_width, var_fw0, var_fwn...) \ - .reg = r, .reg_width = r_width, \ - .cnt = (unsigned long [r_width]) {}, \ - .var_field_width = (unsigned long [r_width]) { var_fw0, var_fwn, 0 }, \ - .enum_ids = (pinmux_enum_t []) - -struct pinmux_data_reg { - unsigned long reg, reg_width, reg_shadow; - pinmux_enum_t *enum_ids; - void __iomem *mapped_reg; -}; - -#define PINMUX_DATA_REG(name, r, r_width) \ - .reg = r, .reg_width = r_width, \ - .enum_ids = (pinmux_enum_t [r_width]) \ - -struct pinmux_irq { - int irq; - pinmux_enum_t *enum_ids; -}; - -#define PINMUX_IRQ(irq_nr, ids...) \ - { .irq = irq_nr, .enum_ids = (pinmux_enum_t []) { ids, 0 } } \ - -struct pinmux_range { - pinmux_enum_t begin; - pinmux_enum_t end; - pinmux_enum_t force; -}; - -struct sh_pfc_soc_info { - char *name; - pinmux_enum_t reserved_id; - struct pinmux_range data; - struct pinmux_range input; - struct pinmux_range input_pd; - struct pinmux_range input_pu; - struct pinmux_range output; - struct pinmux_range mark; - struct pinmux_range function; - - unsigned first_gpio, last_gpio; - - struct pinmux_gpio *gpios; - struct pinmux_cfg_reg *cfg_regs; - struct pinmux_data_reg *data_regs; - - pinmux_enum_t *gpio_data; - unsigned int gpio_data_size; - - struct pinmux_irq *gpio_irq; - unsigned int gpio_irq_size; - - unsigned long unlock_reg; -}; - -enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; - -/* helper macro for port */ -#define PORT_1(fn, pfx, sfx) fn(pfx, sfx) - -#define PORT_10(fn, pfx, sfx) \ - PORT_1(fn, pfx##0, sfx), PORT_1(fn, pfx##1, sfx), \ - PORT_1(fn, pfx##2, sfx), PORT_1(fn, pfx##3, sfx), \ - PORT_1(fn, pfx##4, sfx), PORT_1(fn, pfx##5, sfx), \ - PORT_1(fn, pfx##6, sfx), PORT_1(fn, pfx##7, sfx), \ - PORT_1(fn, pfx##8, sfx), PORT_1(fn, pfx##9, sfx) - -#define PORT_90(fn, pfx, sfx) \ - PORT_10(fn, pfx##1, sfx), PORT_10(fn, pfx##2, sfx), \ - PORT_10(fn, pfx##3, sfx), PORT_10(fn, pfx##4, sfx), \ - PORT_10(fn, pfx##5, sfx), PORT_10(fn, pfx##6, sfx), \ - PORT_10(fn, pfx##7, sfx), PORT_10(fn, pfx##8, sfx), \ - PORT_10(fn, pfx##9, sfx) - -#define _PORT_ALL(pfx, sfx) pfx##_##sfx -#define _GPIO_PORT(pfx, sfx) PINMUX_GPIO(GPIO_PORT##pfx, PORT##pfx##_DATA) -#define PORT_ALL(str) CPU_ALL_PORT(_PORT_ALL, PORT, str) -#define GPIO_PORT_ALL() CPU_ALL_PORT(_GPIO_PORT, , unused) -#define GPIO_FN(str) PINMUX_GPIO(GPIO_FN_##str, str##_MARK) - -/* helper macro for pinmux_enum_t */ -#define PORT_DATA_I(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_IN) - -#define PORT_DATA_I_PD(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, \ - PORT##nr##_IN, PORT##nr##_IN_PD) - -#define PORT_DATA_I_PU(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, \ - PORT##nr##_IN, PORT##nr##_IN_PU) - -#define PORT_DATA_I_PU_PD(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, \ - PORT##nr##_IN, PORT##nr##_IN_PD, PORT##nr##_IN_PU) - -#define PORT_DATA_O(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT) - -#define PORT_DATA_IO(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ - PORT##nr##_IN) - -#define PORT_DATA_IO_PD(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ - PORT##nr##_IN, PORT##nr##_IN_PD) - -#define PORT_DATA_IO_PU(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ - PORT##nr##_IN, PORT##nr##_IN_PU) - -#define PORT_DATA_IO_PU_PD(nr) \ - PINMUX_DATA(PORT##nr##_DATA, PORT##nr##_FN0, PORT##nr##_OUT, \ - PORT##nr##_IN, PORT##nr##_IN_PD, PORT##nr##_IN_PU) - -/* helper macro for top 4 bits in PORTnCR */ -#define _PCRH(in, in_pd, in_pu, out) \ - 0, (out), (in), 0, \ - 0, 0, 0, 0, \ - 0, 0, (in_pd), 0, \ - 0, 0, (in_pu), 0 - -#define PORTCR(nr, reg) \ - { \ - PINMUX_CFG_REG("PORT" nr "CR", reg, 8, 4) { \ - _PCRH(PORT##nr##_IN, PORT##nr##_IN_PD, \ - PORT##nr##_IN_PU, PORT##nr##_OUT), \ - PORT##nr##_FN0, PORT##nr##_FN1, \ - PORT##nr##_FN2, PORT##nr##_FN3, \ - PORT##nr##_FN4, PORT##nr##_FN5, \ - PORT##nr##_FN6, PORT##nr##_FN7 } \ - } - -#endif /* __SH_PFC_H */ -- cgit v1.2.3-59-g8ed1b