* [PATCH v2 00/77] SH pin control and GPIO rework with OF support
From: Laurent Pinchart @ 2012-11-27 0:01 UTC (permalink / raw)
To: linux-sh
Hi everybody,
Here's the second version of the SH pin control and GPIO rework patches. I've
added OF support for PFC instantiation and GPIO mappings that was missing from
v1. PINCTRL bindings are still missing and will come soon.
The first version of this patch set is available at
https://lkml.org/lkml/2012/11/20/823. I haven't applied the ack's I've received
on patches that have been extensively reworked in v2. Sorry for the
inconvenience. All comments received on v1 should have been addressed.
The GPIO DT bindings have been tested on an SH73A0 platform (KZM-A9-GT) with
the on-board GPIO LEDs. Please see patch 71/77 for a question regarding those
bindings.
The patches are still based on top of v3.7-rc6. You can get them from my git
tree at
git://linuxtv.org/pinchartl/fbdev.git pinmux
The code has been compile-tested on all modified platforms except SH7264 and
SH7269, and runtime tested on SH7372 (Mackerel), SH73A0 (KZM-A9-GT) and
R8A7740 (Armadillo) so far. I will runtime test it on R8A7779 (Marzen).
The SH7264 and SH7269 platforms have no gpiolib support so the PFC code can't
be compiled for them. As the currently implemented arch-level pinmux support
also depends on generic GPIO, we're moving from a situation where the code
isn't used to a different situation where the code isn't used. I don't
consider that as a regression.
Sorry for the numerous checkpatch warnings, patches that move code around or
rename files don't modify the content to make review easier, and thus carry
warnings from the existing code.
Changes since v1:
- Split SoC changes in one patch per SoC to make backporting easier
- Dropped SH7267 and SH7277 changes as support for those SoCs will be removed
from the kernel
- Removed the sh_pfc_register() function on ARM
- Added OF support for PFC instantiation and GPIO bindings
- Added PFC DT nodes for the Mackerel and KZM9G boards
- Added GPIO LEDs DT nodes for the KZM9G board
Laurent Pinchart (76):
sh-pfc: Split platform data from the sh_pfc structure
sh-pfc: Move private definitions and declarations to private header
sh-pfc: Merge PFC core and pinctrl
sh-pfc: Merge PFC core and gpio
sh-pfc: Move platform device and driver to the core
sh-pfc: Let the compiler decide whether to inline functions
sh-pfc: Remove check for impossible error condition
sh-pfc: Sort headers alphabetically
sh-pfc: Split platform device and platform driver registration
sh-pfc: Support passing resources through platform device
ARM: shmobile: Select PINCTRL
ARM: shmobile: r8a7740: Register PFC platform device
ARM: shmobile: r8a7779: Register PFC platform device
ARM: shmobile: sh7372: Register PFC platform device
ARM: shmobile: sh73a0: Register PFC platform device
ARM: shmobile: r8a7740: Add pin control resources
ARM: shmobile: sh7372: Add pin control resources
ARM: shmobile: sh73a0: Add pin control resources
sh: Add PFC platform device registration helper function
sh: sh7203: Register PFC platform device
sh: sh7264: Register PFC platform device
sh: sh7269: Register PFC platform device
sh: sh7720: Register PFC platform device
sh: sh7722: Register PFC platform device
sh: sh7723: Register PFC platform device
sh: sh7724: Register PFC platform device
sh: sh7734: Register PFC platform device
sh: sh7757: Register PFC platform device
sh: sh7785: Register PFC platform device
sh: sh7786: Register PFC platform device
sh: shx3: Register PFC platform device
sh-pfc: Remove platform device registration
sh-pfc: Remove unused resource and num_resources platform data fields
sh-pfc: Move driver from drivers/sh/ to drivers/pinctrl/
sh-pfc: Support pinmux info in driver data instead of platform data
sh-pfc: Add r8a7740 pinmux support
sh-pfc: Add r8a7779 pinmux support
sh-pfc: Add sh7372 pinmux support
sh-pfc: Add sh73a0 pinmux support
ARM: shmobile: r8a7740: Use driver-provided pinmux info
ARM: shmobile: r8a7779: Use driver-provided pinmux info
ARM: shmobile: sh7372: Use driver-provided pinmux info
ARM: shmobile: sh73a0: Use driver-provided pinmux info
sh-pfc: Add sh7203 pinmux support
sh-pfc: Add sh7264 pinmux support
sh-pfc: Add sh7269 pinmux support
sh-pfc: Add sh7720 pinmux support
sh-pfc: Add sh7722 pinmux support
sh-pfc: Add sh7723 pinmux support
sh-pfc: Add sh7724 pinmux support
sh-pfc: Add sh7734 pinmux support
sh-pfc: Add sh7757 pinmux support
sh-pfc: Add sh7785 pinmux support
sh-pfc: Add sh7786 pinmux support
sh-pfc: Add shx3 pinmux support
sh: sh7203: pinmux: Use driver-provided pinmux info
sh: sh7264: pinmux: Use driver-provided pinmux info
sh: sh7269: pinmux: Use driver-provided pinmux info
sh: sh7720: pinmux: Use driver-provided pinmux info
sh: sh7722: pinmux: Use driver-provided pinmux info
sh: sh7723: pinmux: Use driver-provided pinmux info
sh: sh7724: pinmux: Use driver-provided pinmux info
sh: sh7734: pinmux: Use driver-provided pinmux info
sh: sh7757: pinmux: Use driver-provided pinmux info
sh: sh7785: pinmux: Use driver-provided pinmux info
sh: sh7786: pinmux: Use driver-provided pinmux info
sh: shx3: pinmux: Use driver-provided pinmux info
sh: Remove unused sh_pfc_register_info() function
sh-pfc: Remove pinmux_info definition
sh-pfc: Move sh_pfc.h from include/linux/ to driver directory
sh-pfc: Add OF support
ARM: shmobile: r8a7740: Add pin control device in device tree
ARM: shmobile: armadillo: Populate platform devices from device tree
ARM: shmobile: kzm9g: Add pin control device in device tree
ARM: shmobile: kzm9g: Populate platform devices from device tree
ARM: shmobile: kzm9g: Add LED1-LED4 to the device tree
Nobuhiro Iwamatsu (1):
ARM: shmobile: Include DTSI of r8a7740 to armadillo800eva
.../bindings/pinctrl/renesas,pfc-pinctrl.txt | 43 +
arch/arm/Kconfig | 1 +
arch/arm/boot/dts/r8a7740-armadillo800eva.dts | 2 +-
arch/arm/boot/dts/r8a7740.dtsi | 6 +
arch/arm/boot/dts/sh73a0-kzm9g.dts | 18 +-
arch/arm/boot/dts/sh73a0.dtsi | 32 +
arch/arm/mach-shmobile/Makefile | 5 -
arch/arm/mach-shmobile/board-armadillo800eva.c | 4 +-
arch/arm/mach-shmobile/board-kzm9g.c | 3 +-
arch/arm/mach-shmobile/setup-r8a7740.c | 26 +
arch/arm/mach-shmobile/setup-r8a7779.c | 25 +
arch/arm/mach-shmobile/setup-sh7372.c | 26 +
arch/arm/mach-shmobile/setup-sh73a0.c | 25 +
arch/sh/Kconfig | 12 +
arch/sh/include/asm/gpio.h | 2 +-
arch/sh/include/cpu-common/cpu/pfc.h | 26 +
arch/sh/kernel/cpu/Makefile | 2 +-
arch/sh/kernel/cpu/pfc.c | 33 +
arch/sh/kernel/cpu/sh2a/pinmux-sh7203.c | 1582 +-----------
arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c | 2121 +---------------
arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c | 2823 +-------------------
arch/sh/kernel/cpu/sh3/pinmux-sh7720.c | 1226 +---------
arch/sh/kernel/cpu/sh4a/pinmux-sh7722.c | 1778 +------------
arch/sh/kernel/cpu/sh4a/pinmux-sh7723.c | 1893 +-------------
arch/sh/kernel/cpu/sh4a/pinmux-sh7724.c | 2210 +---------------
arch/sh/kernel/cpu/sh4a/pinmux-sh7734.c | 2470 +-----------------
arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c | 2267 +----------------
arch/sh/kernel/cpu/sh4a/pinmux-sh7785.c | 1294 +---------
arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c | 822 +------
arch/sh/kernel/cpu/sh4a/pinmux-shx3.c | 573 +----
drivers/pinctrl/Kconfig | 1 +
drivers/pinctrl/Makefile | 1 +
drivers/pinctrl/sh-pfc/Kconfig | 116 +
drivers/pinctrl/sh-pfc/Makefile | 21 +
drivers/{sh/pfc => pinctrl/sh-pfc}/core.c | 294 ++-
drivers/pinctrl/sh-pfc/core.h | 72 +
drivers/{sh/pfc => pinctrl/sh-pfc}/gpio.c | 111 +-
.../pinctrl/sh-pfc}/pfc-r8a7740.c | 11 +-
.../pinctrl/sh-pfc}/pfc-r8a7779.c | 29 +-
drivers/pinctrl/sh-pfc/pfc-sh7203.c | 1592 +++++++++++
drivers/pinctrl/sh-pfc/pfc-sh7264.c | 2131 +++++++++++++++
drivers/pinctrl/sh-pfc/pfc-sh7269.c | 2834 ++++++++++++++++++++
.../pinctrl/sh-pfc}/pfc-sh7372.c | 11 +-
.../pinctrl/sh-pfc}/pfc-sh73a0.c | 11 +-
drivers/pinctrl/sh-pfc/pfc-sh7720.c | 1236 +++++++++
drivers/pinctrl/sh-pfc/pfc-sh7722.c | 1779 ++++++++++++
drivers/pinctrl/sh-pfc/pfc-sh7723.c | 1903 +++++++++++++
drivers/pinctrl/sh-pfc/pfc-sh7724.c | 2225 +++++++++++++++
drivers/pinctrl/sh-pfc/pfc-sh7734.c | 2475 +++++++++++++++++
drivers/pinctrl/sh-pfc/pfc-sh7757.c | 2282 ++++++++++++++++
drivers/pinctrl/sh-pfc/pfc-sh7785.c | 1304 +++++++++
drivers/pinctrl/sh-pfc/pfc-sh7786.c | 837 ++++++
drivers/pinctrl/sh-pfc/pfc-shx3.c | 582 ++++
drivers/{sh/pfc => pinctrl/sh-pfc}/pinctrl.c | 149 +-
{include/linux => drivers/pinctrl/sh-pfc}/sh_pfc.h | 43 +-
drivers/sh/Kconfig | 1 -
drivers/sh/Makefile | 1 -
drivers/sh/pfc/Kconfig | 26 -
drivers/sh/pfc/Makefile | 3 -
59 files changed, 22007 insertions(+), 21424 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
create mode 100644 arch/arm/boot/dts/sh73a0.dtsi
create mode 100644 arch/sh/include/cpu-common/cpu/pfc.h
create mode 100644 arch/sh/kernel/cpu/pfc.c
create mode 100644 drivers/pinctrl/sh-pfc/Kconfig
create mode 100644 drivers/pinctrl/sh-pfc/Makefile
rename drivers/{sh/pfc => pinctrl/sh-pfc}/core.c (62%)
create mode 100644 drivers/pinctrl/sh-pfc/core.h
rename drivers/{sh/pfc => pinctrl/sh-pfc}/gpio.c (59%)
rename {arch/arm/mach-shmobile => drivers/pinctrl/sh-pfc}/pfc-r8a7740.c (99%)
rename {arch/arm/mach-shmobile => drivers/pinctrl/sh-pfc}/pfc-r8a7779.c (99%)
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7203.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7264.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7269.c
rename {arch/arm/mach-shmobile => drivers/pinctrl/sh-pfc}/pfc-sh7372.c (99%)
rename {arch/arm/mach-shmobile => drivers/pinctrl/sh-pfc}/pfc-sh73a0.c (99%)
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7720.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7722.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7723.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7724.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7734.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7757.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7785.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-sh7786.c
create mode 100644 drivers/pinctrl/sh-pfc/pfc-shx3.c
rename drivers/{sh/pfc => pinctrl/sh-pfc}/pinctrl.c (76%)
rename {include/linux => drivers/pinctrl/sh-pfc}/sh_pfc.h (83%)
delete mode 100644 drivers/sh/pfc/Kconfig
delete mode 100644 drivers/sh/pfc/Makefile
--
Regards,
Laurent Pinchart
^ permalink raw reply
* [PATCH v2 01/77] sh-pfc: Split platform data from the sh_pfc structure
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
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 <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/core.c | 89 ++++++++++++++++++++++------------------------
drivers/sh/pfc/gpio.c | 19 +++++-----
drivers/sh/pfc/pinctrl.c | 27 +++++++-------
include/linux/sh_pfc.h | 20 ++++++----
4 files changed, 79 insertions(+), 76 deletions(-)
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 6816937..ecbe51d 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -21,18 +21,13 @@
#include <linux/ioport.h>
#include <linux/pinctrl/machine.h>
-static struct sh_pfc *sh_pfc __read_mostly;
-
-static inline bool sh_pfc_initialized(void)
-{
- return !!sh_pfc;
-}
+static struct sh_pfc sh_pfc __read_mostly;
static void pfc_iounmap(struct sh_pfc *pfc)
{
int k;
- for (k = 0; k < pfc->num_resources; k++)
+ for (k = 0; k < pfc->pdata->num_resources; k++)
if (pfc->window[k].virt)
iounmap(pfc->window[k].virt);
@@ -45,16 +40,16 @@ static int pfc_ioremap(struct sh_pfc *pfc)
struct resource *res;
int k;
- if (!pfc->num_resources)
+ if (!pfc->pdata->num_resources)
return 0;
- pfc->window = kzalloc(pfc->num_resources * sizeof(*pfc->window),
+ pfc->window = kzalloc(pfc->pdata->num_resources * sizeof(*pfc->window),
GFP_NOWAIT);
if (!pfc->window)
goto err1;
- for (k = 0; k < pfc->num_resources; k++) {
- res = pfc->resource + k;
+ for (k = 0; k < pfc->pdata->num_resources; k++) {
+ res = pfc->pdata->resource + k;
WARN_ON(resource_type(res) != IORESOURCE_MEM);
pfc->window[k].phys = res->start;
pfc->window[k].size = resource_size(res);
@@ -79,7 +74,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
int k;
/* scan through physical windows and convert address */
- for (k = 0; k < pfc->num_resources; k++) {
+ for (k = 0; k < pfc->pdata->num_resources; k++) {
window = pfc->window + k;
if (address < window->phys)
@@ -232,8 +227,8 @@ static void write_config_reg(struct sh_pfc *pfc,
data &= mask;
data |= value;
- if (pfc->unlock_reg)
- gpio_write_raw_reg(pfc_phys_to_virt(pfc, pfc->unlock_reg),
+ if (pfc->pdata->unlock_reg)
+ gpio_write_raw_reg(pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg),
32, ~data);
gpio_write_raw_reg(mapped_reg, crp->reg_width, data);
@@ -241,16 +236,16 @@ static void write_config_reg(struct sh_pfc *pfc,
static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
{
- struct pinmux_gpio *gpiop = &pfc->gpios[gpio];
+ struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio];
struct pinmux_data_reg *data_reg;
int k, n;
- if (!enum_in_range(gpiop->enum_id, &pfc->data))
+ if (!enum_in_range(gpiop->enum_id, &pfc->pdata->data))
return -1;
k = 0;
while (1) {
- data_reg = pfc->data_regs + k;
+ data_reg = pfc->pdata->data_regs + k;
if (!data_reg->reg_width)
break;
@@ -279,12 +274,12 @@ static void setup_data_regs(struct sh_pfc *pfc)
struct pinmux_data_reg *drp;
int k;
- for (k = pfc->first_gpio; k <= pfc->last_gpio; k++)
+ for (k = pfc->pdata->first_gpio; k <= pfc->pdata->last_gpio; k++)
setup_data_reg(pfc, k);
k = 0;
while (1) {
- drp = pfc->data_regs + k;
+ drp = pfc->pdata->data_regs + k;
if (!drp->reg_width)
break;
@@ -298,15 +293,15 @@ static void 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->gpios[gpio];
+ struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio];
int k, n;
- if (!enum_in_range(gpiop->enum_id, &pfc->data))
+ if (!enum_in_range(gpiop->enum_id, &pfc->pdata->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->data_regs + k;
+ *drp = pfc->pdata->data_regs + k;
*bitp = n;
return 0;
}
@@ -323,7 +318,7 @@ static int get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
k = 0;
while (1) {
- config_reg = pfc->cfg_regs + k;
+ config_reg = pfc->pdata->cfg_regs + k;
r_width = config_reg->reg_width;
f_width = config_reg->field_width;
@@ -361,12 +356,12 @@ static int 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->gpios[gpio].enum_id;
- pinmux_enum_t *data = pfc->gpio_data;
+ pinmux_enum_t enum_id = pfc->pdata->gpios[gpio].enum_id;
+ pinmux_enum_t *data = pfc->pdata->gpio_data;
int k;
- if (!enum_in_range(enum_id, &pfc->data)) {
- if (!enum_in_range(enum_id, &pfc->mark)) {
+ if (!enum_in_range(enum_id, &pfc->pdata->data)) {
+ if (!enum_in_range(enum_id, &pfc->pdata->mark)) {
pr_err("non data/mark enum_id for gpio %d\n", gpio);
return -1;
}
@@ -377,7 +372,7 @@ int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos,
return pos + 1;
}
- for (k = 0; k < pfc->gpio_data_size; k++) {
+ for (k = 0; k < pfc->pdata->gpio_data_size; k++) {
if (data[k] = enum_id) {
*enum_idp = data[k + 1];
return k + 1;
@@ -405,19 +400,19 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
break;
case PINMUX_TYPE_OUTPUT:
- range = &pfc->output;
+ range = &pfc->pdata->output;
break;
case PINMUX_TYPE_INPUT:
- range = &pfc->input;
+ range = &pfc->pdata->input;
break;
case PINMUX_TYPE_INPUT_PULLUP:
- range = &pfc->input_pu;
+ range = &pfc->pdata->input_pu;
break;
case PINMUX_TYPE_INPUT_PULLDOWN:
- range = &pfc->input_pd;
+ range = &pfc->pdata->input_pd;
break;
default:
@@ -437,7 +432,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 = enum_in_range(enum_id, &pfc->function);
+ in_range = enum_in_range(enum_id, &pfc->pdata->function);
if (!in_range) {
/* not a function enum */
if (range) {
@@ -502,7 +497,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
}
EXPORT_SYMBOL_GPL(sh_pfc_config_gpio);
-int register_sh_pfc(struct sh_pfc *pfc)
+int register_sh_pfc(struct sh_pfc_platform_data *pdata)
{
int (*initroutine)(struct sh_pfc *) = NULL;
int ret;
@@ -512,26 +507,28 @@ int register_sh_pfc(struct sh_pfc *pfc)
*/
BUILD_BUG_ON(PINMUX_FLAG_TYPE > ((1 << PINMUX_FLAG_DBIT_SHIFT) - 1));
- if (sh_pfc)
+ if (sh_pfc.pdata)
return -EBUSY;
- ret = pfc_ioremap(pfc);
- if (unlikely(ret < 0))
+ sh_pfc.pdata = pdata;
+
+ ret = pfc_ioremap(&sh_pfc);
+ if (unlikely(ret < 0)) {
+ sh_pfc.pdata = NULL;
return ret;
+ }
- spin_lock_init(&pfc->lock);
+ spin_lock_init(&sh_pfc.lock);
pinctrl_provide_dummies();
- setup_data_regs(pfc);
-
- sh_pfc = pfc;
+ setup_data_regs(&sh_pfc);
/*
* Initialize pinctrl bindings first
*/
initroutine = symbol_request(sh_pfc_register_pinctrl);
if (initroutine) {
- ret = (*initroutine)(pfc);
+ ret = (*initroutine)(&sh_pfc);
symbol_put_addr(initroutine);
if (unlikely(ret != 0))
@@ -546,7 +543,7 @@ int register_sh_pfc(struct sh_pfc *pfc)
*/
initroutine = symbol_request(sh_pfc_register_gpiochip);
if (initroutine) {
- ret = (*initroutine)(pfc);
+ ret = (*initroutine)(&sh_pfc);
symbol_put_addr(initroutine);
/*
@@ -560,13 +557,13 @@ int register_sh_pfc(struct sh_pfc *pfc)
}
}
- pr_info("%s support registered\n", pfc->name);
+ pr_info("%s support registered\n", sh_pfc.pdata->name);
return 0;
err:
- pfc_iounmap(pfc);
- sh_pfc = NULL;
+ pfc_iounmap(&sh_pfc);
+ sh_pfc.pdata = NULL;
return ret;
}
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index 038fa07..9b7e45c 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -103,11 +103,11 @@ static int sh_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
if (pos <= 0 || !enum_id)
break;
- for (i = 0; i < pfc->gpio_irq_size; i++) {
- enum_ids = pfc->gpio_irq[i].enum_ids;
+ for (i = 0; i < pfc->pdata->gpio_irq_size; i++) {
+ enum_ids = pfc->pdata->gpio_irq[i].enum_ids;
for (k = 0; enum_ids[k]; k++) {
if (enum_ids[k] = enum_id)
- return pfc->gpio_irq[i].irq;
+ return pfc->pdata->gpio_irq[i].irq;
}
}
}
@@ -128,12 +128,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->first_gpio != 0); /* needs testing */
+ WARN_ON(pfc->pdata->first_gpio != 0); /* needs testing */
- gc->label = pfc->name;
+ gc->label = pfc->pdata->name;
gc->owner = THIS_MODULE;
- gc->base = pfc->first_gpio;
- gc->ngpio = (pfc->last_gpio - pfc->first_gpio) + 1;
+ gc->base = pfc->pdata->first_gpio;
+ gc->ngpio = (pfc->pdata->last_gpio - pfc->pdata->first_gpio) + 1;
}
int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
@@ -154,7 +154,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
kfree(chip);
pr_info("%s handling gpio %d -> %d\n",
- pfc->name, pfc->first_gpio, pfc->last_gpio);
+ pfc->pdata->name, pfc->pdata->first_gpio,
+ pfc->pdata->last_gpio);
return ret;
}
@@ -179,7 +180,7 @@ static int __devinit sh_pfc_gpio_probe(struct platform_device *pdev)
chip = gpio_to_pfc_chip(gc);
platform_set_drvdata(pdev, chip);
- pr_info("attaching to GPIO chip %s\n", chip->pfc->name);
+ pr_info("attaching to GPIO chip %s\n", chip->pfc->pdata->name);
return 0;
}
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index 0646bf6..447fb60 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/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->gpios[offset].flags & PINMUX_FLAG_TYPE;
+ pinmux_type = pfc->pdata->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->gpios[offset].flags &= ~PINMUX_FLAG_TYPE;
- pfc->gpios[offset].flags |= new_type;
+ pfc->pdata->gpios[offset].flags &= ~PINMUX_FLAG_TYPE;
+ pfc->pdata->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->gpios[offset].flags & PINMUX_FLAG_TYPE;
+ pinmux_type = pfc->pdata->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->gpios[offset].flags & PINMUX_FLAG_TYPE;
+ pinmux_type = pfc->pdata->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->gpios[pin].flags & PINMUX_FLAG_TYPE;
+ *config = pfc->pdata->gpios[pin].flags & PINMUX_FLAG_TYPE;
return 0;
}
@@ -357,7 +357,7 @@ static int __devinit sh_pfc_map_gpios(struct sh_pfc *pfc,
unsigned long flags;
int i;
- pmx->nr_pads = pfc->last_gpio - pfc->first_gpio + 1;
+ pmx->nr_pads = pfc->pdata->last_gpio - pfc->pdata->first_gpio + 1;
pmx->pads = kmalloc(sizeof(struct pinctrl_pin_desc) * pmx->nr_pads,
GFP_KERNEL);
@@ -376,9 +376,9 @@ static int __devinit sh_pfc_map_gpios(struct sh_pfc *pfc,
*/
for (i = 0; i < pmx->nr_pads; i++) {
struct pinctrl_pin_desc *pin = pmx->pads + i;
- struct pinmux_gpio *gpio = pfc->gpios + i;
+ struct pinmux_gpio *gpio = pfc->pdata->gpios + i;
- pin->number = pfc->first_gpio + i;
+ pin->number = pfc->pdata->first_gpio + i;
pin->name = gpio->name;
/* XXX */
@@ -410,7 +410,7 @@ static int __devinit sh_pfc_map_functions(struct sh_pfc *pfc,
spin_lock_irqsave(&pmx->lock, flags);
for (i = fn = 0; i < pmx->nr_pads; i++) {
- struct pinmux_gpio *gpio = pfc->gpios + i;
+ struct pinmux_gpio *gpio = pfc->pdata->gpios + i;
if ((gpio->flags & PINMUX_FLAG_TYPE) = PINMUX_TYPE_FUNCTION)
pmx->functions[fn++] = gpio;
@@ -446,9 +446,10 @@ static int __devinit sh_pfc_pinctrl_probe(struct platform_device *pdev)
goto free_functions;
}
- sh_pfc_gpio_range.npins = pfc->last_gpio - pfc->first_gpio + 1;
- sh_pfc_gpio_range.base = pfc->first_gpio;
- sh_pfc_gpio_range.pin_base = pfc->first_gpio;
+ 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;
pinctrl_add_gpio_range(sh_pfc_pmx->pctl, &sh_pfc_gpio_range);
diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h
index c19a092..58587f9 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 };
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 02/77] sh-pfc: Move private definitions and declarations to private header
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
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 <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
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
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index ecbe51d..72421a4 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -21,6 +21,8 @@
#include <linux/ioport.h>
#include <linux/pinctrl/machine.h>
+#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 0000000..b07ae25
--- /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 <linux/compiler.h>
+#include <linux/sh_pfc.h>
+#include <linux/types.h>
+
+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 9b7e45c..94c5489 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -19,6 +19,8 @@
#include <linux/pinctrl/consumer.h>
#include <linux/sh_pfc.h>
+#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 447fb60..5efa36a 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -24,6 +24,8 @@
#include <linux/pinctrl/pinmux.h>
#include <linux/pinctrl/pinconf-generic.h>
+#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 58587f9..f7f01b2 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)
{
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 03/77] sh-pfc: Merge PFC core and pinctrl
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
The PFC core is only used by the pinctrl and gpio modules. As the gpio
module depends on the pinctrl module, the pinctrl module will always be
present if the core gets used. There is thus no point in keeping core
and pinctrl in two seperate modules. Merge them.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/Kconfig | 10 +---------
drivers/sh/pfc/Makefile | 4 ++--
drivers/sh/pfc/core.c | 15 +++------------
drivers/sh/pfc/pinctrl.c | 3 +--
4 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/drivers/sh/pfc/Kconfig b/drivers/sh/pfc/Kconfig
index 804f9ad..f33d82a 100644
--- a/drivers/sh/pfc/Kconfig
+++ b/drivers/sh/pfc/Kconfig
@@ -5,18 +5,10 @@ config SH_PFC
depends on GENERIC_GPIO
select GPIO_SH_PFC if ARCH_REQUIRE_GPIOLIB
select PINCTRL_SH_PFC
- def_bool y
-
-#
-# Placeholder for now, rehome to drivers/pinctrl once the PFC APIs
-# have settled.
-#
-config PINCTRL_SH_PFC
- tristate "SuperH PFC pin controller driver"
- depends on SH_PFC
select PINCTRL
select PINMUX
select PINCONF
+ def_bool y
config GPIO_SH_PFC
tristate "SuperH PFC GPIO support"
diff --git a/drivers/sh/pfc/Makefile b/drivers/sh/pfc/Makefile
index 7916027..ce6fae3 100644
--- a/drivers/sh/pfc/Makefile
+++ b/drivers/sh/pfc/Makefile
@@ -1,3 +1,3 @@
-obj-y += core.o
-obj-$(CONFIG_PINCTRL_SH_PFC) += pinctrl.o
+sh-pfc-objs = core.o pinctrl.o
+obj-y += sh-pfc.o
obj-$(CONFIG_GPIO_SH_PFC) += gpio.o
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 72421a4..30e33db 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -8,7 +8,7 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
-#define pr_fmt(fmt) "sh_pfc " KBUILD_MODNAME ": " fmt
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -497,7 +497,6 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
out_err:
return -1;
}
-EXPORT_SYMBOL_GPL(sh_pfc_config_gpio);
int register_sh_pfc(struct sh_pfc_platform_data *pdata)
{
@@ -528,17 +527,9 @@ int register_sh_pfc(struct sh_pfc_platform_data *pdata)
/*
* Initialize pinctrl bindings first
*/
- initroutine = symbol_request(sh_pfc_register_pinctrl);
- if (initroutine) {
- ret = (*initroutine)(&sh_pfc);
- symbol_put_addr(initroutine);
-
- if (unlikely(ret != 0))
- goto err;
- } else {
- pr_err("failed to initialize pinctrl bindings\n");
+ ret = sh_pfc_register_pinctrl(&sh_pfc);
+ if (unlikely(ret != 0))
goto err;
- }
/*
* Then the GPIO chip
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index 5efa36a..0bde9fa 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -9,7 +9,7 @@
*/
#define DRV_NAME "pinctrl-sh_pfc"
-#define pr_fmt(fmt) DRV_NAME " " KBUILD_MODNAME ": " fmt
+#define pr_fmt(fmt) KBUILD_MODNAME " pinctrl: " fmt
#include <linux/init.h>
#include <linux/module.h>
@@ -523,7 +523,6 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
return sh_pfc_pinctrl_init();
}
-EXPORT_SYMBOL_GPL(sh_pfc_register_pinctrl);
static void __exit sh_pfc_pinctrl_exit(void)
{
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 04/77] sh-pfc: Merge PFC core and gpio
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
The PFC core calls the gpio module gpiochip registration in its
register_sh_pfc() function, itself called at arch initialization time.
If the gpio module isn't present then the gpiochip will never be
registered.
As the gpio module can only be present at arch initialization time if
it's builtin, there's no point in allowing to build it as a module. Make
it a boolean option, and initialize it synchronously with the core if
selected.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/Kconfig | 2 +-
drivers/sh/pfc/Makefile | 4 ++-
drivers/sh/pfc/core.c | 23 +++++--------
drivers/sh/pfc/core.h | 4 ++
drivers/sh/pfc/gpio.c | 79 +++++------------------------------------------
5 files changed, 25 insertions(+), 87 deletions(-)
diff --git a/drivers/sh/pfc/Kconfig b/drivers/sh/pfc/Kconfig
index f33d82a..eaeabc5 100644
--- a/drivers/sh/pfc/Kconfig
+++ b/drivers/sh/pfc/Kconfig
@@ -11,7 +11,7 @@ config SH_PFC
def_bool y
config GPIO_SH_PFC
- tristate "SuperH PFC GPIO support"
+ bool "SuperH PFC GPIO support"
depends on SH_PFC && GPIOLIB
help
This enables support for GPIOs within the SoC's pin function
diff --git a/drivers/sh/pfc/Makefile b/drivers/sh/pfc/Makefile
index ce6fae3..6315cf3 100644
--- a/drivers/sh/pfc/Makefile
+++ b/drivers/sh/pfc/Makefile
@@ -1,3 +1,5 @@
sh-pfc-objs = core.o pinctrl.o
+ifeq ($(CONFIG_GPIO_SH_PFC),y)
+sh-pfc-objs += gpio.o
+endif
obj-y += sh-pfc.o
-obj-$(CONFIG_GPIO_SH_PFC) += gpio.o
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 30e33db..f8f458b 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -149,7 +149,6 @@ int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos)
return (gpio_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1;
}
-EXPORT_SYMBOL_GPL(sh_pfc_read_bit);
void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos,
unsigned long value)
@@ -169,7 +168,6 @@ void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos,
gpio_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow);
}
-EXPORT_SYMBOL_GPL(sh_pfc_write_bit);
static void config_reg_helper(struct sh_pfc *pfc,
struct pinmux_cfg_reg *crp,
@@ -307,7 +305,6 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
*bitp = n;
return 0;
}
-EXPORT_SYMBOL_GPL(sh_pfc_get_data_reg);
static int get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
struct pinmux_cfg_reg **crp,
@@ -384,7 +381,6 @@ int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos,
pr_err("cannot locate data/mark enum_id for gpio %d\n", gpio);
return -1;
}
-EXPORT_SYMBOL_GPL(sh_pfc_gpio_to_enum);
int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
int cfg_mode)
@@ -500,7 +496,6 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
int register_sh_pfc(struct sh_pfc_platform_data *pdata)
{
- int (*initroutine)(struct sh_pfc *) = NULL;
int ret;
/*
@@ -531,24 +526,20 @@ int register_sh_pfc(struct sh_pfc_platform_data *pdata)
if (unlikely(ret != 0))
goto err;
+#ifdef CONFIG_GPIO_SH_PFC
/*
* Then the GPIO chip
*/
- initroutine = symbol_request(sh_pfc_register_gpiochip);
- if (initroutine) {
- ret = (*initroutine)(&sh_pfc);
- symbol_put_addr(initroutine);
-
+ ret = sh_pfc_register_gpiochip(&sh_pfc);
+ if (unlikely(ret != 0)) {
/*
* If the GPIO chip fails to come up we still leave the
* PFC state as it is, given that there are already
* extant users of it that have succeeded by this point.
*/
- if (unlikely(ret != 0)) {
- pr_notice("failed to init GPIO chip, ignoring...\n");
- ret = 0;
- }
+ pr_notice("failed to init GPIO chip, ignoring...\n");
}
+#endif
pr_info("%s support registered\n", sh_pfc.pdata->name);
@@ -560,3 +551,7 @@ err:
return ret;
}
+
+MODULE_AUTHOR("Magnus Damm, Paul Mundt");
+MODULE_DESCRIPTION("Pin Control and GPIO driver for SuperH pin function controller");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h
index b07ae25..f3032b2 100644
--- a/drivers/sh/pfc/core.h
+++ b/drivers/sh/pfc/core.h
@@ -20,14 +20,18 @@ struct pfc_window {
unsigned long size;
};
+struct sh_pfc_chip;
+
struct sh_pfc {
struct sh_pfc_platform_data *pdata;
spinlock_t lock;
struct pfc_window *window;
+ struct sh_pfc_chip *gpio;
};
int sh_pfc_register_gpiochip(struct sh_pfc *pfc);
+int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc);
int sh_pfc_register_pinctrl(struct sh_pfc *pfc);
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index 94c5489..91ea4c9 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -15,7 +15,6 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/module.h>
-#include <linux/platform_device.h>
#include <linux/pinctrl/consumer.h>
#include <linux/sh_pfc.h>
@@ -152,44 +151,23 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
sh_pfc_gpio_setup(chip);
ret = gpiochip_add(&chip->gpio_chip);
- if (unlikely(ret < 0))
+ if (unlikely(ret < 0)) {
kfree(chip);
+ return ret;
+ }
+
+ pfc->gpio = chip;
pr_info("%s handling gpio %d -> %d\n",
pfc->pdata->name, pfc->pdata->first_gpio,
pfc->pdata->last_gpio);
- return ret;
-}
-EXPORT_SYMBOL_GPL(sh_pfc_register_gpiochip);
-
-static int sh_pfc_gpio_match(struct gpio_chip *gc, void *data)
-{
- return !!strstr(gc->label, data);
-}
-
-static int __devinit sh_pfc_gpio_probe(struct platform_device *pdev)
-{
- struct sh_pfc_chip *chip;
- struct gpio_chip *gc;
-
- gc = gpiochip_find("_pfc", sh_pfc_gpio_match);
- if (unlikely(!gc)) {
- pr_err("Cant find gpio chip\n");
- return -ENODEV;
- }
-
- chip = gpio_to_pfc_chip(gc);
- platform_set_drvdata(pdev, chip);
-
- pr_info("attaching to GPIO chip %s\n", chip->pfc->pdata->name);
-
return 0;
}
-static int __devexit sh_pfc_gpio_remove(struct platform_device *pdev)
+int __exit sh_pfc_unregister_gpiochip(struct sh_pfc *pfc)
{
- struct sh_pfc_chip *chip = platform_get_drvdata(pdev);
+ struct sh_pfc_chip *chip = pfc->gpio;
int ret;
ret = gpiochip_remove(&chip->gpio_chip);
@@ -197,47 +175,6 @@ static int __devexit sh_pfc_gpio_remove(struct platform_device *pdev)
return ret;
kfree(chip);
+ pfc->gpio = NULL;
return 0;
}
-
-static struct platform_driver sh_pfc_gpio_driver = {
- .probe = sh_pfc_gpio_probe,
- .remove = __devexit_p(sh_pfc_gpio_remove),
- .driver = {
- .name = KBUILD_MODNAME,
- .owner = THIS_MODULE,
- },
-};
-
-static struct platform_device sh_pfc_gpio_device = {
- .name = KBUILD_MODNAME,
- .id = -1,
-};
-
-static int __init sh_pfc_gpio_init(void)
-{
- int rc;
-
- rc = platform_driver_register(&sh_pfc_gpio_driver);
- if (likely(!rc)) {
- rc = platform_device_register(&sh_pfc_gpio_device);
- if (unlikely(rc))
- platform_driver_unregister(&sh_pfc_gpio_driver);
- }
-
- return rc;
-}
-
-static void __exit sh_pfc_gpio_exit(void)
-{
- platform_device_unregister(&sh_pfc_gpio_device);
- platform_driver_unregister(&sh_pfc_gpio_driver);
-}
-
-module_init(sh_pfc_gpio_init);
-module_exit(sh_pfc_gpio_exit);
-
-MODULE_AUTHOR("Magnus Damm, Paul Mundt");
-MODULE_DESCRIPTION("GPIO driver for SuperH pin function controller");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:pfc-gpio");
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 05/77] sh-pfc: Move platform device and driver to the core
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
The pinctrl module registers both a platform device and a platform
driver. The only purpose of this awkward construction is to have a
device to pass to the pinctrl registration function.
As a first step to get rid of this hack, move the platform device and
driver from the pinctrl module to the core. The platform device will
then be moved to arch code.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/core.c | 101 +++++++++++++++++++++++++++++++++++++--------
drivers/sh/pfc/core.h | 4 ++
drivers/sh/pfc/gpio.c | 3 +-
drivers/sh/pfc/pinctrl.c | 100 +++++++++++----------------------------------
4 files changed, 114 insertions(+), 94 deletions(-)
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index f8f458b..3593de5 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -8,6 +8,8 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
+
+#define DRV_NAME "sh-pfc"
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/errno.h>
@@ -20,11 +22,10 @@
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/pinctrl/machine.h>
+#include <linux/platform_device.h>
#include "core.h"
-static struct sh_pfc sh_pfc __read_mostly;
-
static void pfc_iounmap(struct sh_pfc *pfc)
{
int k;
@@ -494,8 +495,10 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
return -1;
}
-int register_sh_pfc(struct sh_pfc_platform_data *pdata)
+static int sh_pfc_probe(struct platform_device *pdev)
{
+ struct sh_pfc_platform_data *pdata = pdev->dev.platform_data;
+ struct sh_pfc *pfc;
int ret;
/*
@@ -503,26 +506,29 @@ int register_sh_pfc(struct sh_pfc_platform_data *pdata)
*/
BUILD_BUG_ON(PINMUX_FLAG_TYPE > ((1 << PINMUX_FLAG_DBIT_SHIFT) - 1));
- if (sh_pfc.pdata)
- return -EBUSY;
+ if (pdata = NULL)
+ return -ENODEV;
- sh_pfc.pdata = pdata;
+ pfc = devm_kzalloc(&pdev->dev, sizeof(pfc), GFP_KERNEL);
+ if (pfc = NULL)
+ return -ENOMEM;
- ret = pfc_ioremap(&sh_pfc);
- if (unlikely(ret < 0)) {
- sh_pfc.pdata = NULL;
+ pfc->pdata = pdata;
+ pfc->dev = &pdev->dev;
+
+ ret = pfc_ioremap(pfc);
+ if (unlikely(ret < 0))
return ret;
- }
- spin_lock_init(&sh_pfc.lock);
+ spin_lock_init(&pfc->lock);
pinctrl_provide_dummies();
- setup_data_regs(&sh_pfc);
+ setup_data_regs(pfc);
/*
* Initialize pinctrl bindings first
*/
- ret = sh_pfc_register_pinctrl(&sh_pfc);
+ ret = sh_pfc_register_pinctrl(pfc);
if (unlikely(ret != 0))
goto err;
@@ -530,7 +536,7 @@ int register_sh_pfc(struct sh_pfc_platform_data *pdata)
/*
* Then the GPIO chip
*/
- ret = sh_pfc_register_gpiochip(&sh_pfc);
+ ret = sh_pfc_register_gpiochip(pfc);
if (unlikely(ret != 0)) {
/*
* If the GPIO chip fails to come up we still leave the
@@ -541,17 +547,76 @@ int register_sh_pfc(struct sh_pfc_platform_data *pdata)
}
#endif
- pr_info("%s support registered\n", sh_pfc.pdata->name);
+ platform_set_drvdata(pdev, pfc);
+
+ pr_info("%s support registered\n", pdata->name);
return 0;
err:
- pfc_iounmap(&sh_pfc);
- sh_pfc.pdata = NULL;
-
+ pfc_iounmap(pfc);
return ret;
}
+static int __devexit sh_pfc_remove(struct platform_device *pdev)
+{
+ struct sh_pfc *pfc = platform_get_drvdata(pdev);
+
+#ifdef CONFIG_GPIO_SH_PFC
+ sh_pfc_unregister_gpiochip(pfc);
+#endif
+ sh_pfc_unregister_pinctrl(pfc);
+
+ pfc_iounmap(pfc);
+
+ platform_set_drvdata(pdev, NULL);
+
+ return 0;
+}
+
+static const struct platform_device_id sh_pfc_id_table[] = {
+ { "sh-pfc", 0 },
+ { },
+};
+MODULE_DEVICE_TABLE(platform, sh_pfc_id_table);
+
+static struct platform_driver sh_pfc_driver = {
+ .probe = sh_pfc_probe,
+ .remove = __devexit_p(sh_pfc_remove),
+ .id_table = sh_pfc_id_table,
+ .driver = {
+ .name = DRV_NAME,
+ .owner = THIS_MODULE,
+ },
+};
+
+static struct platform_device sh_pfc_device = {
+ .name = DRV_NAME,
+ .id = -1,
+};
+
+int __init register_sh_pfc(struct sh_pfc_platform_data *pdata)
+{
+ int rc;
+
+ sh_pfc_device.dev.platform_data = pdata;
+
+ rc = platform_driver_register(&sh_pfc_driver);
+ if (likely(!rc)) {
+ rc = platform_device_register(&sh_pfc_device);
+ if (unlikely(rc))
+ platform_driver_unregister(&sh_pfc_driver);
+ }
+
+ return rc;
+}
+
+static void __exit sh_pfc_exit(void)
+{
+ platform_driver_unregister(&sh_pfc_driver);
+}
+module_exit(sh_pfc_exit);
+
MODULE_AUTHOR("Magnus Damm, Paul Mundt");
MODULE_DESCRIPTION("Pin Control and GPIO driver for SuperH pin function controller");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h
index f3032b2..1287b3e 100644
--- a/drivers/sh/pfc/core.h
+++ b/drivers/sh/pfc/core.h
@@ -21,19 +21,23 @@ struct pfc_window {
};
struct sh_pfc_chip;
+struct sh_pfc_pinctrl;
struct sh_pfc {
+ struct device *dev;
struct sh_pfc_platform_data *pdata;
spinlock_t lock;
struct pfc_window *window;
struct sh_pfc_chip *gpio;
+ struct sh_pfc_pinctrl *pinctrl;
};
int sh_pfc_register_gpiochip(struct sh_pfc *pfc);
int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc);
int sh_pfc_register_pinctrl(struct sh_pfc *pfc);
+int sh_pfc_unregister_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,
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index 91ea4c9..f22d43a 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -8,7 +8,8 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
-#define pr_fmt(fmt) "sh_pfc " KBUILD_MODNAME ": " fmt
+
+#define pr_fmt(fmt) KBUILD_MODNAME " gpio: " fmt
#include <linux/init.h>
#include <linux/gpio.h>
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index 0bde9fa..1c93e3c 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -7,8 +7,8 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
-#define DRV_NAME "pinctrl-sh_pfc"
+#define DRV_NAME "sh-pfc"
#define pr_fmt(fmt) KBUILD_MODNAME " pinctrl: " fmt
#include <linux/init.h>
@@ -17,7 +17,6 @@
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/platform_device.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf.h>
@@ -39,8 +38,6 @@ struct sh_pfc_pinctrl {
spinlock_t lock;
};
-static struct sh_pfc_pinctrl *sh_pfc_pmx;
-
static int sh_pfc_get_groups_count(struct pinctrl_dev *pctldev)
{
struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
@@ -423,28 +420,31 @@ static int __devinit sh_pfc_map_functions(struct sh_pfc *pfc,
return 0;
}
-static int __devinit sh_pfc_pinctrl_probe(struct platform_device *pdev)
+int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
{
- struct sh_pfc *pfc;
+ struct sh_pfc_pinctrl *pmx;
int ret;
- if (unlikely(!sh_pfc_pmx))
- return -ENODEV;
+ pmx = kzalloc(sizeof(struct sh_pfc_pinctrl), GFP_KERNEL);
+ if (unlikely(!pmx))
+ return -ENOMEM;
+
+ spin_lock_init(&pmx->lock);
- pfc = sh_pfc_pmx->pfc;
+ pmx->pfc = pfc;
+ pfc->pinctrl = pmx;
- ret = sh_pfc_map_gpios(pfc, sh_pfc_pmx);
+ ret = sh_pfc_map_gpios(pfc, pmx);
if (unlikely(ret != 0))
return ret;
- ret = sh_pfc_map_functions(pfc, sh_pfc_pmx);
+ ret = sh_pfc_map_functions(pfc, pmx);
if (unlikely(ret != 0))
goto free_pads;
- sh_pfc_pmx->pctl = pinctrl_register(&sh_pfc_pinctrl_desc, &pdev->dev,
- sh_pfc_pmx);
- if (IS_ERR(sh_pfc_pmx->pctl)) {
- ret = PTR_ERR(sh_pfc_pmx->pctl);
+ pmx->pctl = pinctrl_register(&sh_pfc_pinctrl_desc, pfc->dev, pmx);
+ if (IS_ERR(pmx->pctl)) {
+ ret = PTR_ERR(pmx->pctl);
goto free_functions;
}
@@ -453,79 +453,29 @@ static int __devinit sh_pfc_pinctrl_probe(struct platform_device *pdev)
sh_pfc_gpio_range.base = pfc->pdata->first_gpio;
sh_pfc_gpio_range.pin_base = pfc->pdata->first_gpio;
- pinctrl_add_gpio_range(sh_pfc_pmx->pctl, &sh_pfc_gpio_range);
-
- platform_set_drvdata(pdev, sh_pfc_pmx);
+ pinctrl_add_gpio_range(pmx->pctl, &sh_pfc_gpio_range);
return 0;
free_functions:
- kfree(sh_pfc_pmx->functions);
+ kfree(pmx->functions);
free_pads:
- kfree(sh_pfc_pmx->pads);
- kfree(sh_pfc_pmx);
+ kfree(pmx->pads);
+ kfree(pmx);
return ret;
}
-static int __devexit sh_pfc_pinctrl_remove(struct platform_device *pdev)
+int __devexit sh_pfc_unregister_pinctrl(struct sh_pfc *pfc)
{
- struct sh_pfc_pinctrl *pmx = platform_get_drvdata(pdev);
+ struct sh_pfc_pinctrl *pmx = pfc->pinctrl;
pinctrl_unregister(pmx->pctl);
- platform_set_drvdata(pdev, NULL);
-
- kfree(sh_pfc_pmx->functions);
- kfree(sh_pfc_pmx->pads);
- kfree(sh_pfc_pmx);
+ kfree(pmx->functions);
+ kfree(pmx->pads);
+ kfree(pmx);
+ pfc->pinctrl = NULL;
return 0;
}
-
-static struct platform_driver sh_pfc_pinctrl_driver = {
- .probe = sh_pfc_pinctrl_probe,
- .remove = __devexit_p(sh_pfc_pinctrl_remove),
- .driver = {
- .name = DRV_NAME,
- .owner = THIS_MODULE,
- },
-};
-
-static struct platform_device sh_pfc_pinctrl_device = {
- .name = DRV_NAME,
- .id = -1,
-};
-
-static int sh_pfc_pinctrl_init(void)
-{
- int rc;
-
- rc = platform_driver_register(&sh_pfc_pinctrl_driver);
- if (likely(!rc)) {
- rc = platform_device_register(&sh_pfc_pinctrl_device);
- if (unlikely(rc))
- platform_driver_unregister(&sh_pfc_pinctrl_driver);
- }
-
- return rc;
-}
-
-int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
-{
- sh_pfc_pmx = kzalloc(sizeof(struct sh_pfc_pinctrl), GFP_KERNEL);
- if (unlikely(!sh_pfc_pmx))
- return -ENOMEM;
-
- spin_lock_init(&sh_pfc_pmx->lock);
-
- sh_pfc_pmx->pfc = pfc;
-
- return sh_pfc_pinctrl_init();
-}
-
-static void __exit sh_pfc_pinctrl_exit(void)
-{
- platform_driver_unregister(&sh_pfc_pinctrl_driver);
-}
-module_exit(sh_pfc_pinctrl_exit);
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 06/77] sh-pfc: Let the compiler decide whether to inline functions
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
The compiler should be smart enough to automatically inline static
functions that are called from a single location.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/pinctrl.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index 1c93e3c..21b8678 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -115,7 +115,7 @@ static void sh_pfc_noop_disable(struct pinctrl_dev *pctldev, unsigned func,
{
}
-static inline int sh_pfc_config_function(struct sh_pfc *pfc, unsigned offset)
+static int sh_pfc_config_function(struct sh_pfc *pfc, unsigned offset)
{
if (sh_pfc_config_gpio(pfc, offset,
PINMUX_TYPE_FUNCTION,
@@ -327,10 +327,10 @@ static struct pinctrl_desc sh_pfc_pinctrl_desc = {
.confops = &sh_pfc_pinconf_ops,
};
-static inline void __devinit sh_pfc_map_one_gpio(struct sh_pfc *pfc,
- struct sh_pfc_pinctrl *pmx,
- struct pinmux_gpio *gpio,
- unsigned offset)
+static void __devinit sh_pfc_map_one_gpio(struct sh_pfc *pfc,
+ struct sh_pfc_pinctrl *pmx,
+ struct pinmux_gpio *gpio,
+ unsigned offset)
{
struct pinmux_data_reg *dummy;
unsigned long flags;
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 07/77] sh-pfc: Remove check for impossible error condition
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
The pfc pointer can't be NULL in the get and set value functions, remove
the error check.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/gpio.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index f22d43a..0a85159 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -51,7 +51,7 @@ static void sh_gpio_set_value(struct sh_pfc *pfc, unsigned gpio, int value)
struct pinmux_data_reg *dr = NULL;
int bit = 0;
- if (!pfc || sh_pfc_get_data_reg(pfc, gpio, &dr, &bit) != 0)
+ if (sh_pfc_get_data_reg(pfc, gpio, &dr, &bit) != 0)
BUG();
else
sh_pfc_write_bit(dr, bit, value);
@@ -62,7 +62,7 @@ static int sh_gpio_get_value(struct sh_pfc *pfc, unsigned gpio)
struct pinmux_data_reg *dr = NULL;
int bit = 0;
- if (!pfc || sh_pfc_get_data_reg(pfc, gpio, &dr, &bit) != 0)
+ if (sh_pfc_get_data_reg(pfc, gpio, &dr, &bit) != 0)
return -EINVAL;
return sh_pfc_read_bit(dr, bit);
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 08/77] sh-pfc: Sort headers alphabetically
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/core.c | 10 +++++-----
drivers/sh/pfc/gpio.c | 6 +++---
drivers/sh/pfc/pinctrl.c | 6 +++---
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 3593de5..f1a0c85 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -12,15 +12,15 @@
#define DRV_NAME "sh-pfc"
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/bitops.h>
+#include <linux/err.h>
#include <linux/errno.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
#include <linux/kernel.h>
-#include <linux/sh_pfc.h>
#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/bitops.h>
+#include <linux/sh_pfc.h>
#include <linux/slab.h>
-#include <linux/ioport.h>
#include <linux/pinctrl/machine.h>
#include <linux/platform_device.h>
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index 0a85159..9f4f0fd 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -11,13 +11,13 @@
#define pr_fmt(fmt) KBUILD_MODNAME " gpio: " fmt
-#include <linux/init.h>
#include <linux/gpio.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
+#include <linux/init.h>
#include <linux/module.h>
#include <linux/pinctrl/consumer.h>
#include <linux/sh_pfc.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
#include "core.h"
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index 21b8678..c0c8271 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -11,17 +11,17 @@
#define DRV_NAME "sh-pfc"
#define pr_fmt(fmt) KBUILD_MODNAME " pinctrl: " fmt
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sh_pfc.h>
-#include <linux/err.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/pinctrl/consumer.h>
-#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf.h>
-#include <linux/pinctrl/pinmux.h>
#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
#include "core.h"
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 09/77] sh-pfc: Split platform device and platform driver registration
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Move platform driver registration to a static postcore initcall. This
prepares the move of platform device registration to arch code.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/core.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index f1a0c85..9736e3d 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -597,19 +597,16 @@ static struct platform_device sh_pfc_device = {
int __init register_sh_pfc(struct sh_pfc_platform_data *pdata)
{
- int rc;
-
sh_pfc_device.dev.platform_data = pdata;
- rc = platform_driver_register(&sh_pfc_driver);
- if (likely(!rc)) {
- rc = platform_device_register(&sh_pfc_device);
- if (unlikely(rc))
- platform_driver_unregister(&sh_pfc_driver);
- }
+ return platform_device_register(&sh_pfc_device);
+}
- return rc;
+static int __init sh_pfc_init(void)
+{
+ return platform_driver_register(&sh_pfc_driver);
}
+postcore_initcall(sh_pfc_init);
static void __exit sh_pfc_exit(void)
{
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 10/77] sh-pfc: Support passing resources through platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Resources should be passed through the platform device, not through
platform data. Default to platform device resources and fall back to
platform data resources if not available.
Support for platform data resources will be removed when arch code will
be converted.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
drivers/sh/pfc/core.c | 29 +++++++++++++++++++++--------
drivers/sh/pfc/core.h | 2 ++
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 9736e3d..4e4adc7 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -30,29 +30,42 @@ static void pfc_iounmap(struct sh_pfc *pfc)
{
int k;
- for (k = 0; k < pfc->pdata->num_resources; k++)
+ for (k = 0; k < pfc->num_windows; k++)
if (pfc->window[k].virt)
iounmap(pfc->window[k].virt);
kfree(pfc->window);
+ pfc->num_windows = 0;
pfc->window = NULL;
}
-static int pfc_ioremap(struct sh_pfc *pfc)
+static int pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev)
{
+ unsigned int num_resources;
struct resource *res;
int k;
- if (!pfc->pdata->num_resources)
+ 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) {
+ pfc->num_windows = 0;
return 0;
+ }
- pfc->window = kzalloc(pfc->pdata->num_resources * sizeof(*pfc->window),
+ pfc->window = kzalloc(num_resources * sizeof(*pfc->window),
GFP_NOWAIT);
if (!pfc->window)
goto err1;
- for (k = 0; k < pfc->pdata->num_resources; k++) {
- res = pfc->pdata->resource + k;
+ pfc->num_windows = num_resources;
+
+ for (k = 0; k < num_resources; k++, res++) {
WARN_ON(resource_type(res) != IORESOURCE_MEM);
pfc->window[k].phys = res->start;
pfc->window[k].size = resource_size(res);
@@ -77,7 +90,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
int k;
/* scan through physical windows and convert address */
- for (k = 0; k < pfc->pdata->num_resources; k++) {
+ for (k = 0; k < pfc->num_windows; k++) {
window = pfc->window + k;
if (address < window->phys)
@@ -516,7 +529,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
pfc->pdata = pdata;
pfc->dev = &pdev->dev;
- ret = pfc_ioremap(pfc);
+ ret = pfc_ioremap(pfc, pdev);
if (unlikely(ret < 0))
return ret;
diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h
index 1287b3e..b71f559 100644
--- a/drivers/sh/pfc/core.h
+++ b/drivers/sh/pfc/core.h
@@ -28,7 +28,9 @@ struct sh_pfc {
struct sh_pfc_platform_data *pdata;
spinlock_t lock;
+ unsigned int num_windows;
struct pfc_window *window;
+
struct sh_pfc_chip *gpio;
struct sh_pfc_pinctrl *pinctrl;
};
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 11/77] ARM: shmobile: Select PINCTRL
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
The pin control framework is required by mach-shmobile. Select it in
Kconfig.
This will be required when the sh-pfc driver will move to
drivers/pinctrl/.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
arch/arm/Kconfig | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ade7e92..3eaa434 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -693,6 +693,7 @@ config ARCH_SHMOBILE
select MULTI_IRQ_HANDLER
select NEED_MACH_MEMORY_H
select NO_IOPORT
+ select PINCTRL
select PM_GENERIC_DOMAINS if PM
select SPARSE_IRQ
help
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 12/77] ARM: shmobile: r8a7740: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/arm/mach-shmobile/pfc-r8a7740.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-shmobile/pfc-r8a7740.c b/arch/arm/mach-shmobile/pfc-r8a7740.c
index 134d1b9..8a412b1 100644
--- a/arch/arm/mach-shmobile/pfc-r8a7740.c
+++ b/arch/arm/mach-shmobile/pfc-r8a7740.c
@@ -20,6 +20,7 @@
*/
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/platform_device.h>
#include <linux/sh_pfc.h>
#include <mach/r8a7740.h>
#include <mach/irqs.h>
@@ -2611,7 +2612,15 @@ static struct pinmux_info r8a7740_pinmux_info = {
.gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
};
+static struct platform_device r8a7740_pfc_device = {
+ .name = "sh-pfc",
+ .id = -1,
+ .dev = {
+ .platform_data = &r8a7740_pinmux_info,
+ },
+};
+
void r8a7740_pinmux_init(void)
{
- register_pinmux(&r8a7740_pinmux_info);
+ platform_device_register(&r8a7740_pfc_device);
}
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 13/77] ARM: shmobile: r8a7779: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/arm/mach-shmobile/pfc-r8a7779.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-shmobile/pfc-r8a7779.c b/arch/arm/mach-shmobile/pfc-r8a7779.c
index cbc26ba..187ae97 100644
--- a/arch/arm/mach-shmobile/pfc-r8a7779.c
+++ b/arch/arm/mach-shmobile/pfc-r8a7779.c
@@ -19,6 +19,7 @@
*/
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/platform_device.h>
#include <linux/sh_pfc.h>
#include <linux/ioport.h>
#include <mach/r8a7779.h>
@@ -2616,9 +2617,6 @@ static struct resource r8a7779_pfc_resources[] = {
static struct pinmux_info r8a7779_pinmux_info = {
.name = "r8a7779_pfc",
- .resource = r8a7779_pfc_resources,
- .num_resources = ARRAY_SIZE(r8a7779_pfc_resources),
-
.unlock_reg = 0xfffc0000, /* PMMR */
.reserved_id = PINMUX_RESERVED,
@@ -2639,7 +2637,17 @@ static struct pinmux_info r8a7779_pinmux_info = {
.gpio_data_size = ARRAY_SIZE(pinmux_data),
};
+static struct platform_device r8a7779_pfc_device = {
+ .name = "sh-pfc",
+ .id = -1,
+ .resource = r8a7779_pfc_resources,
+ .num_resources = ARRAY_SIZE(r8a7779_pfc_resources),
+ .dev = {
+ .platform_data = &r8a7779_pinmux_info,
+ },
+};
+
void r8a7779_pinmux_init(void)
{
- register_pinmux(&r8a7779_pinmux_info);
+ platform_device_register(&r8a7779_pfc_device);
}
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 14/77] ARM: shmobile: sh7372: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/arm/mach-shmobile/pfc-sh7372.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-shmobile/pfc-sh7372.c b/arch/arm/mach-shmobile/pfc-sh7372.c
index 7a1525f..dd5e145 100644
--- a/arch/arm/mach-shmobile/pfc-sh7372.c
+++ b/arch/arm/mach-shmobile/pfc-sh7372.c
@@ -22,6 +22,7 @@
*/
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/platform_device.h>
#include <linux/sh_pfc.h>
#include <mach/irqs.h>
#include <mach/sh7372.h>
@@ -1657,7 +1658,15 @@ static struct pinmux_info sh7372_pinmux_info = {
.gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
};
+static struct platform_device sh7372_pfc_device = {
+ .name = "sh-pfc",
+ .id = -1,
+ .dev = {
+ .platform_data = &sh7372_pinmux_info,
+ },
+};
+
void sh7372_pinmux_init(void)
{
- register_pinmux(&sh7372_pinmux_info);
+ platform_device_register(&sh7372_pfc_device);
}
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 15/77] ARM: shmobile: sh73a0: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/arm/mach-shmobile/pfc-sh73a0.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-shmobile/pfc-sh73a0.c b/arch/arm/mach-shmobile/pfc-sh73a0.c
index b442f9d..c83c582 100644
--- a/arch/arm/mach-shmobile/pfc-sh73a0.c
+++ b/arch/arm/mach-shmobile/pfc-sh73a0.c
@@ -20,6 +20,7 @@
*/
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/platform_device.h>
#include <linux/sh_pfc.h>
#include <mach/sh73a0.h>
#include <mach/irqs.h>
@@ -2797,7 +2798,15 @@ static struct pinmux_info sh73a0_pinmux_info = {
.gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
};
+static struct platform_device sh73a0_pfc_device = {
+ .name = "sh-pfc",
+ .id = -1,
+ .dev = {
+ .platform_data = &sh73a0_pinmux_info,
+ },
+};
+
void sh73a0_pinmux_init(void)
{
- register_pinmux(&sh73a0_pinmux_info);
+ platform_device_register(&sh73a0_pfc_device);
}
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 16/77] ARM: shmobile: r8a7740: Add pin control resources
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
arch/arm/mach-shmobile/pfc-r8a7740.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-shmobile/pfc-r8a7740.c b/arch/arm/mach-shmobile/pfc-r8a7740.c
index 8a412b1..84ef85d 100644
--- a/arch/arm/mach-shmobile/pfc-r8a7740.c
+++ b/arch/arm/mach-shmobile/pfc-r8a7740.c
@@ -18,7 +18,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <linux/bug.h>
#include <linux/init.h>
+#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/sh_pfc.h>
@@ -2612,9 +2614,24 @@ static struct pinmux_info r8a7740_pinmux_info = {
.gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
};
+static struct resource r8a7740_pfc_resources[] = {
+ [0] = {
+ .start = 0xe6050000,
+ .end = 0xe6057fff,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = 0xe605800c,
+ .end = 0xe605802b,
+ .flags = IORESOURCE_MEM,
+ }
+};
+
static struct platform_device r8a7740_pfc_device = {
.name = "sh-pfc",
.id = -1,
+ .resource = r8a7740_pfc_resources,
+ .num_resources = ARRAY_SIZE(r8a7740_pfc_resources),
.dev = {
.platform_data = &r8a7740_pinmux_info,
},
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 17/77] ARM: shmobile: sh7372: Add pin control resources
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
arch/arm/mach-shmobile/pfc-sh7372.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-shmobile/pfc-sh7372.c b/arch/arm/mach-shmobile/pfc-sh7372.c
index dd5e145..91016b4 100644
--- a/arch/arm/mach-shmobile/pfc-sh7372.c
+++ b/arch/arm/mach-shmobile/pfc-sh7372.c
@@ -20,7 +20,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <linux/bug.h>
#include <linux/init.h>
+#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/sh_pfc.h>
@@ -1658,9 +1660,24 @@ static struct pinmux_info sh7372_pinmux_info = {
.gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
};
+static struct resource sh7372_pfc_resources[] = {
+ [0] = {
+ .start = 0xe6050000,
+ .end = 0xe6057fff,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = 0xe605800c,
+ .end = 0xe6058027,
+ .flags = IORESOURCE_MEM,
+ }
+};
+
static struct platform_device sh7372_pfc_device = {
.name = "sh-pfc",
.id = -1,
+ .resource = sh7372_pfc_resources,
+ .num_resources = ARRAY_SIZE(sh7372_pfc_resources),
.dev = {
.platform_data = &sh7372_pinmux_info,
},
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 18/77] ARM: shmobile: sh73a0: Add pin control resources
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
arch/arm/mach-shmobile/pfc-sh73a0.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-shmobile/pfc-sh73a0.c b/arch/arm/mach-shmobile/pfc-sh73a0.c
index c83c582..342683e 100644
--- a/arch/arm/mach-shmobile/pfc-sh73a0.c
+++ b/arch/arm/mach-shmobile/pfc-sh73a0.c
@@ -18,7 +18,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <linux/bug.h>
#include <linux/init.h>
+#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/sh_pfc.h>
@@ -2798,9 +2800,24 @@ static struct pinmux_info sh73a0_pinmux_info = {
.gpio_irq_size = ARRAY_SIZE(pinmux_irqs),
};
+static struct resource sh73a0_pfc_resources[] = {
+ [0] = {
+ .start = 0xe6050000,
+ .end = 0xe6057fff,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = 0xe605801c,
+ .end = 0xe6058027,
+ .flags = IORESOURCE_MEM,
+ }
+};
+
static struct platform_device sh73a0_pfc_device = {
.name = "sh-pfc",
.id = -1,
+ .resource = sh73a0_pfc_resources,
+ .num_resources = ARRAY_SIZE(sh73a0_pfc_resources),
.dev = {
.platform_data = &sh73a0_pinmux_info,
},
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 19/77] sh: Add PFC platform device registration helper function
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
The sh_pfc_register() function can be called by boards or SoC setup code
to register the PFC platform device.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/sh/include/cpu-common/cpu/pfc.h | 30 +++++++++++++++++++++++
arch/sh/kernel/cpu/Makefile | 2 +-
arch/sh/kernel/cpu/pfc.c | 44 ++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 1 deletions(-)
create mode 100644 arch/sh/include/cpu-common/cpu/pfc.h
create mode 100644 arch/sh/kernel/cpu/pfc.c
diff --git a/arch/sh/include/cpu-common/cpu/pfc.h b/arch/sh/include/cpu-common/cpu/pfc.h
new file mode 100644
index 0000000..40e8643
--- /dev/null
+++ b/arch/sh/include/cpu-common/cpu/pfc.h
@@ -0,0 +1,30 @@
+/*
+ * SH Pin Function Control Initialization
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ARCH_SH_CPU_PFC_H__
+#define __ARCH_SH_CPU_PFC_H__
+
+#include <linux/types.h>
+
+struct pinmux_info;
+struct resource;
+
+int sh_pfc_register(const char *name,
+ struct resource *resource, u32 num_resources);
+int sh_pfc_register_info(const char *name,
+ struct resource *resource, u32 num_resources,
+ struct pinmux_info *pdata);
+
+#endif /* __ARCH_SH_CPU_PFC_H__ */
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index fa58bfd..accc7ca 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -18,4 +18,4 @@ obj-$(CONFIG_ARCH_SHMOBILE) += shmobile/
obj-$(CONFIG_SH_ADC) += adc.o
obj-$(CONFIG_SH_CLK_CPG_LEGACY) += clock-cpg.o
-obj-y += irq/ init.o clock.o fpu.o proc.o
+obj-y += irq/ init.o clock.o fpu.o pfc.o proc.o
diff --git a/arch/sh/kernel/cpu/pfc.c b/arch/sh/kernel/cpu/pfc.c
new file mode 100644
index 0000000..d045d75
--- /dev/null
+++ b/arch/sh/kernel/cpu/pfc.c
@@ -0,0 +1,44 @@
+/*
+ * SH Pin Function Control Initialization
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <cpu/pfc.h>
+
+static struct platform_device sh_pfc_device = {
+ .name = "sh-pfc",
+ .id = -1,
+};
+
+int __init sh_pfc_register(const char *name,
+ struct resource *resource, u32 num_resources)
+{
+ if (name)
+ sh_pfc_device.name = name;
+ sh_pfc_device.num_resources = num_resources;
+ sh_pfc_device.resource = resource;
+
+ return platform_device_register(&sh_pfc_device);
+}
+
+int __init sh_pfc_register_info(const char *name,
+ struct resource *resource, u32 num_resources,
+ struct pinmux_info *pdata)
+{
+ sh_pfc_device.dev.platform_data = pdata;
+
+ return sh_pfc_register(name, resource, num_resources);
+}
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 20/77] sh: sh7203: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/sh/Kconfig | 1 +
arch/sh/kernel/cpu/sh2a/pinmux-sh7203.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index babc2b8..023b2ad 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -276,6 +276,7 @@ config CPU_SUBTYPE_SH7203
select SYS_SUPPORTS_CMT
select SYS_SUPPORTS_MTU2
select ARCH_WANT_OPTIONAL_GPIOLIB
+ select PINCTRL
config CPU_SUBTYPE_SH7206
bool "Support SH7206 processor"
diff --git a/arch/sh/kernel/cpu/sh2a/pinmux-sh7203.c b/arch/sh/kernel/cpu/sh2a/pinmux-sh7203.c
index c465af7..814926e 100644
--- a/arch/sh/kernel/cpu/sh2a/pinmux-sh7203.c
+++ b/arch/sh/kernel/cpu/sh2a/pinmux-sh7203.c
@@ -11,6 +11,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
+#include <cpu/pfc.h>
#include <cpu/sh7203.h>
enum {
@@ -1592,6 +1593,6 @@ static struct pinmux_info sh7203_pinmux_info = {
static int __init plat_pinmux_setup(void)
{
- return register_pinmux(&sh7203_pinmux_info);
+ return sh_pfc_register_info(NULL, NULL, 0, &sh7203_pinmux_info);
}
arch_initcall(plat_pinmux_setup);
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 21/77] sh: sh7264: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/sh/Kconfig | 1 +
arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 023b2ad..0626044 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -297,6 +297,7 @@ config CPU_SUBTYPE_SH7264
select CPU_HAS_FPU
select SYS_SUPPORTS_CMT
select SYS_SUPPORTS_MTU2
+ select PINCTRL
config CPU_SUBTYPE_SH7269
bool "Support SH7269 processor"
diff --git a/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c b/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c
index b055b55..80b9544 100644
--- a/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c
+++ b/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c
@@ -11,6 +11,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
+#include <cpu/pfc.h>
#include <cpu/sh7264.h>
enum {
@@ -2131,6 +2132,6 @@ static struct pinmux_info sh7264_pinmux_info = {
static int __init plat_pinmux_setup(void)
{
- return register_pinmux(&sh7264_pinmux_info);
+ return sh_pfc_register_info(NULL, NULL, 0, &sh7264_pinmux_info);
}
arch_initcall(plat_pinmux_setup);
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 22/77] sh: sh7269: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/sh/Kconfig | 1 +
arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 0626044..b934d7d 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -305,6 +305,7 @@ config CPU_SUBTYPE_SH7269
select CPU_HAS_FPU
select SYS_SUPPORTS_CMT
select SYS_SUPPORTS_MTU2
+ select PINCTRL
config CPU_SUBTYPE_MXG
bool "Support MX-G processor"
diff --git a/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c b/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
index 039e458..e27525b 100644
--- a/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
+++ b/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
@@ -12,6 +12,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
+#include <cpu/pfc.h>
#include <cpu/sh7269.h>
enum {
@@ -2834,6 +2835,6 @@ static struct pinmux_info sh7269_pinmux_info = {
static int __init plat_pinmux_setup(void)
{
- return register_pinmux(&sh7269_pinmux_info);
+ return sh_pfc_register_info(NULL, NULL, 0, &sh7269_pinmux_info);
}
arch_initcall(plat_pinmux_setup);
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 23/77] sh: sh7720: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/sh/Kconfig | 1 +
arch/sh/kernel/cpu/sh3/pinmux-sh7720.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index b934d7d..bfb8b3e 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -367,6 +367,7 @@ config CPU_SUBTYPE_SH7720
select ARCH_WANT_OPTIONAL_GPIOLIB
select USB_ARCH_HAS_OHCI
select USB_OHCI_SH if USB_OHCI_HCD
+ select PINCTRL
help
Select SH7720 if you have a SH3-DSP SH7720 CPU.
diff --git a/arch/sh/kernel/cpu/sh3/pinmux-sh7720.c b/arch/sh/kernel/cpu/sh3/pinmux-sh7720.c
index 9ca1546..df0648f 100644
--- a/arch/sh/kernel/cpu/sh3/pinmux-sh7720.c
+++ b/arch/sh/kernel/cpu/sh3/pinmux-sh7720.c
@@ -11,6 +11,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
+#include <cpu/pfc.h>
#include <cpu/sh7720.h>
enum {
@@ -1236,7 +1237,7 @@ static struct pinmux_info sh7720_pinmux_info = {
static int __init plat_pinmux_setup(void)
{
- return register_pinmux(&sh7720_pinmux_info);
+ return sh_pfc_register_info(NULL, NULL, 0, &sh7720_pinmux_info);
}
arch_initcall(plat_pinmux_setup);
--
1.7.8.6
^ permalink raw reply related
* [PATCH v2 24/77] sh: sh7722: Register PFC platform device
From: Laurent Pinchart @ 2012-11-27 0:02 UTC (permalink / raw)
To: linux-sh
Add arch code to register the PFC platform device instead of calling the
driver directly. Platform device registration in the sh-pfc driver will
be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
arch/sh/Kconfig | 1 +
arch/sh/kernel/cpu/sh4a/pinmux-sh7722.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index bfb8b3e..2f0d9bf 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -527,6 +527,7 @@ config CPU_SUBTYPE_SH7722
select SYS_SUPPORTS_NUMA
select SYS_SUPPORTS_CMT
select ARCH_WANT_OPTIONAL_GPIOLIB
+ select PINCTRL
config CPU_SUBTYPE_SH7366
bool "Support SH7366 processor"
diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-sh7722.c b/arch/sh/kernel/cpu/sh4a/pinmux-sh7722.c
index 0688a75..11dbce3 100644
--- a/arch/sh/kernel/cpu/sh4a/pinmux-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-sh7722.c
@@ -1,6 +1,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
+#include <cpu/pfc.h>
#include <cpu/sh7722.h>
enum {
@@ -1778,7 +1779,7 @@ static struct pinmux_info sh7722_pinmux_info = {
static int __init plat_pinmux_setup(void)
{
- return register_pinmux(&sh7722_pinmux_info);
+ return sh_pfc_register_info(NULL, NULL, 0, &sh7722_pinmux_info);
}
arch_initcall(plat_pinmux_setup);
--
1.7.8.6
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox