Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 3/4] ARM: OMAP2: MUSB: Specify omap4 has mailbox
From: Kishon Vijay Abraham I @ 2013-01-25  2:19 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080391-5120-1-git-send-email-kishon@ti.com>

Added has_mailbox to the musb platform data to specify that omap uses
an external mailbox (in control module) to communicate with the musb
core during device connect and disconnect.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 arch/arm/mach-omap2/usb-musb.c |    3 +++
 include/linux/usb/musb.h       |    2 ++
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 7b33b37..9d27e3f 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -85,6 +85,9 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
 	musb_plat.mode = board_data->mode;
 	musb_plat.extvbus = board_data->extvbus;
 
+	if (cpu_is_omap44xx())
+		musb_plat.has_mailbox = true;
+
 	if (soc_is_am35xx()) {
 		oh_name = "am35x_otg_hs";
 		name = "musb-am35x";
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index eb50525..053c268 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -99,6 +99,8 @@ struct musb_hdrc_platform_data {
 	/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
 	u8		mode;
 
+	u8		has_mailbox:1;
+
 	/* for clk_get() */
 	const char	*clock;
 
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH v3 4/4] drivers: usb: start using the control module driver
From: Kishon Vijay Abraham I @ 2013-01-25  2:19 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080391-5120-1-git-send-email-kishon@ti.com>

Start using the control module driver for powering on the PHY and for
writing to the mailbox instead of writing to the control module
registers on their own.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 Documentation/devicetree/bindings/usb/omap-usb.txt |    4 ++
 Documentation/devicetree/bindings/usb/usb-phy.txt  |    7 +-
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c         |   13 ----
 drivers/usb/musb/Kconfig                           |    1 +
 drivers/usb/musb/omap2430.c                        |   68 +++++++-------------
 drivers/usb/musb/omap2430.h                        |    9 ---
 drivers/usb/phy/Kconfig                            |    1 +
 drivers/usb/phy/omap-usb2.c                        |   41 +++---------
 include/linux/usb/omap_usb.h                       |    4 +-
 9 files changed, 40 insertions(+), 108 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt
index 2d8c6c4..704b684 100644
--- a/Documentation/devicetree/bindings/usb/omap-usb.txt
+++ b/Documentation/devicetree/bindings/usb/omap-usb.txt
@@ -3,6 +3,9 @@ OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS
 OMAP MUSB GLUE
  - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb"
  - ti,hwmods : must be "usb_otg_hs"
+ - ti,has_mailbox : to specify that omap uses an external mailbox
+   (in control module) to communicate with the musb core during device connect
+   and disconnect.
  - multipoint : Should be "1" indicating the musb controller supports
    multipoint. This is a MUSB configuration-specific setting.
  - num_eps : Specifies the number of endpoints. This is also a
@@ -24,6 +27,7 @@ SOC specific device node entry
 usb_otg_hs: usb_otg_hs at 4a0ab000 {
 	compatible = "ti,omap4-musb";
 	ti,hwmods = "usb_otg_hs";
+	ti,has_mailbox;
 	multipoint = <1>;
 	num_eps = <16>;
 	ram_bits = <12>;
diff --git a/Documentation/devicetree/bindings/usb/usb-phy.txt b/Documentation/devicetree/bindings/usb/usb-phy.txt
index 2466b6f..48761a2 100644
--- a/Documentation/devicetree/bindings/usb/usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/usb-phy.txt
@@ -4,9 +4,7 @@ OMAP USB2 PHY
 
 Required properties:
  - compatible: Should be "ti,omap-usb2"
- - reg : Address and length of the register set for the device. Also
-add the address of control module dev conf register until a driver for
-control module is added
+ - reg : Address and length of the register set for the device.
 
 Optional properties:
  - ctrl_module : phandle of the control module used by PHY driver to power on
@@ -16,7 +14,6 @@ This is usually a subnode of ocp2scp to which it is connected.
 
 usb2phy at 4a0ad080 {
 	compatible = "ti,omap-usb2";
-	reg = <0x4a0ad080 0x58>,
-	      <0x4a002300 0x4>;
+	reg = <0x4a0ad080 0x58>;
 	ctrl_module = <&omap_control_usb>;
 };
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 129d508..103f4ba 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2698,13 +2698,6 @@ static struct resource omap44xx_usb_phy_and_pll_addrs[] = {
 		.end		= 0x4a0ae000,
 		.flags		= IORESOURCE_MEM,
 	},
-	{
-		/* XXX: Remove this once control module driver is in place */
-		.name		= "ctrl_dev",
-		.start		= 0x4a002300,
-		.end		= 0x4a002303,
-		.flags		= IORESOURCE_MEM,
-	},
 	{ }
 };
 
@@ -6152,12 +6145,6 @@ static struct omap_hwmod_addr_space omap44xx_usb_otg_hs_addrs[] = {
 		.pa_end		= 0x4a0ab7ff,
 		.flags		= ADDR_TYPE_RT
 	},
-	{
-		/* XXX: Remove this once control module driver is in place */
-		.pa_start	= 0x4a00233c,
-		.pa_end		= 0x4a00233f,
-		.flags		= ADDR_TYPE_RT
-	},
 	{ }
 };
 
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 23a0b7f..de6e5ce 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -11,6 +11,7 @@ config USB_MUSB_HDRC
 	select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX)
 	select TWL4030_USB if MACH_OMAP_3430SDP
 	select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
+	select OMAP_CONTROL_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
 	select USB_OTG_UTILS
 	help
 	  Say Y here if your system has a dual role high speed USB
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index da00af4..88a601b 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -37,6 +37,7 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/usb/musb-omap.h>
+#include <linux/usb/omap_control_usb.h>
 
 #include "musb_core.h"
 #include "omap2430.h"
@@ -46,7 +47,7 @@ struct omap2430_glue {
 	struct platform_device	*musb;
 	enum omap_musb_vbus_id_status status;
 	struct work_struct	omap_musb_mailbox_work;
-	u32 __iomem		*control_otghs;
+	struct device		*control_otghs;
 };
 #define glue_to_musb(g)		platform_get_drvdata(g->musb)
 
@@ -54,26 +55,6 @@ struct omap2430_glue		*_glue;
 
 static struct timer_list musb_idle_timer;
 
-/**
- * omap4_usb_phy_mailbox - write to usb otg mailbox
- * @glue: struct omap2430_glue *
- * @val: the value to be written to the mailbox
- *
- * On detection of a device (ID pin is grounded), this API should be called
- * to set AVALID, VBUSVALID and ID pin is grounded.
- *
- * When OMAP is connected to a host (OMAP in device mode), this API
- * is called to set AVALID, VBUSVALID and ID pin in high impedance.
- *
- * XXX: This function will be removed once we have a seperate driver for
- * control module
- */
-static void omap4_usb_phy_mailbox(struct omap2430_glue *glue, u32 val)
-{
-	if (glue->control_otghs)
-		writel(val, glue->control_otghs);
-}
-
 static void musb_do_idle(unsigned long _musb)
 {
 	struct musb	*musb = (void *)_musb;
@@ -269,7 +250,6 @@ EXPORT_SYMBOL_GPL(omap_musb_mailbox);
 
 static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 {
-	u32 val;
 	struct musb *musb = glue_to_musb(glue);
 	struct device *dev = musb->controller;
 	struct musb_hdrc_platform_data *pdata = dev->platform_data;
@@ -285,8 +265,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		musb->xceiv->last_event = USB_EVENT_ID;
 		if (musb->gadget_driver) {
 			pm_runtime_get_sync(dev);
-			val = AVALID | VBUSVALID;
-			omap4_usb_phy_mailbox(glue, val);
+			omap_control_usb_set_mode(glue->control_otghs,
+				USB_MODE_HOST);
 			omap2430_musb_set_vbus(musb, 1);
 		}
 		break;
@@ -299,8 +279,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 		musb->xceiv->last_event = USB_EVENT_VBUS;
 		if (musb->gadget_driver)
 			pm_runtime_get_sync(dev);
-		val = IDDIG | AVALID | VBUSVALID;
-		omap4_usb_phy_mailbox(glue, val);
+		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
 		break;
 
 	case OMAP_MUSB_ID_FLOAT:
@@ -317,8 +296,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
 			if (musb->xceiv->otg->set_vbus)
 				otg_set_vbus(musb->xceiv->otg, 0);
 		}
-		val = SESSEND | IDDIG;
-		omap4_usb_phy_mailbox(glue, val);
+		omap_control_usb_set_mode(glue->control_otghs,
+			USB_MODE_DISCONNECT);
 		break;
 	default:
 		dev_dbg(dev, "ID float\n");
@@ -415,7 +394,6 @@ err1:
 static void omap2430_musb_enable(struct musb *musb)
 {
 	u8		devctl;
-	u32		val;
 	unsigned long timeout = jiffies + msecs_to_jiffies(1000);
 	struct device *dev = musb->controller;
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
@@ -425,8 +403,7 @@ static void omap2430_musb_enable(struct musb *musb)
 	switch (glue->status) {
 
 	case OMAP_MUSB_ID_GROUND:
-		val = AVALID | VBUSVALID;
-		omap4_usb_phy_mailbox(glue, val);
+		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
 		if (data->interface_type != MUSB_INTERFACE_UTMI)
 			break;
 		devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
@@ -445,8 +422,7 @@ static void omap2430_musb_enable(struct musb *musb)
 		break;
 
 	case OMAP_MUSB_VBUS_VALID:
-		val = IDDIG | AVALID | VBUSVALID;
-		omap4_usb_phy_mailbox(glue, val);
+		omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
 		break;
 
 	default:
@@ -456,14 +432,12 @@ static void omap2430_musb_enable(struct musb *musb)
 
 static void omap2430_musb_disable(struct musb *musb)
 {
-	u32 val;
 	struct device *dev = musb->controller;
 	struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
 
-	if (glue->status != OMAP_MUSB_UNKNOWN) {
-		val = SESSEND | IDDIG;
-		omap4_usb_phy_mailbox(glue, val);
-	}
+	if (glue->status != OMAP_MUSB_UNKNOWN)
+		omap_control_usb_set_mode(glue->control_otghs,
+			USB_MODE_DISCONNECT);
 }
 
 static int omap2430_musb_exit(struct musb *musb)
@@ -498,7 +472,6 @@ static int omap2430_probe(struct platform_device *pdev)
 	struct omap2430_glue		*glue;
 	struct device_node		*np = pdev->dev.of_node;
 	struct musb_hdrc_config		*config;
-	struct resource			*res;
 	int				ret = -ENOMEM;
 
 	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
@@ -521,12 +494,6 @@ static int omap2430_probe(struct platform_device *pdev)
 	glue->musb			= musb;
 	glue->status			= OMAP_MUSB_UNKNOWN;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-
-	glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res);
-	if (glue->control_otghs == NULL)
-		dev_dbg(&pdev->dev, "Failed to obtain control memory\n");
-
 	if (np) {
 		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 		if (!pdata) {
@@ -558,11 +525,22 @@ static int omap2430_probe(struct platform_device *pdev)
 		of_property_read_u32(np, "ram_bits", (u32 *)&config->ram_bits);
 		of_property_read_u32(np, "power", (u32 *)&pdata->power);
 		config->multipoint = of_property_read_bool(np, "multipoint");
+		pdata->has_mailbox = of_property_read_bool(np,
+		    "ti,has_mailbox");
 
 		pdata->board_data	= data;
 		pdata->config		= config;
 	}
 
+	if (pdata->has_mailbox) {
+		glue->control_otghs = omap_get_control_dev();
+		if (IS_ERR(glue->control_otghs)) {
+			dev_vdbg(&pdev->dev, "Failed to get control device\n");
+			return -ENODEV;
+		}
+	} else {
+		glue->control_otghs = ERR_PTR(-ENODEV);
+	}
 	pdata->platform_ops		= &omap2430_ops;
 
 	platform_set_drvdata(pdev, glue);
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h
index 8ef6566..1b5e83a 100644
--- a/drivers/usb/musb/omap2430.h
+++ b/drivers/usb/musb/omap2430.h
@@ -49,13 +49,4 @@
 #define OTG_FORCESTDBY		0x414
 #	define	ENABLEFORCE		(1 << 0)
 
-/*
- * Control Module bit definitions
- * XXX: Will be removed once we have a driver for control module.
- */
-#define	AVALID				BIT(0)
-#define	BVALID				BIT(1)
-#define	VBUSVALID			BIT(2)
-#define	SESSEND				BIT(3)
-#define	IDDIG				BIT(4)
 #endif	/* __MUSB_OMAP243X_H__ */
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 65b6a80..fe6f616 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -8,6 +8,7 @@ config OMAP_USB2
 	tristate "OMAP USB2 PHY Driver"
 	depends on ARCH_OMAP2PLUS
 	select USB_OTG_UTILS
+	select OMAP_CONTROL_USB
 	help
 	  Enable this to support the transceiver that is part of SOC. This
 	  driver takes care of all the PHY functionality apart from comparator.
diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c
index 26ae8f4..c2b4c8e 100644
--- a/drivers/usb/phy/omap-usb2.c
+++ b/drivers/usb/phy/omap-usb2.c
@@ -27,6 +27,7 @@
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/delay.h>
+#include <linux/usb/omap_control_usb.h>
 
 /**
  * omap_usb2_set_comparator - links the comparator present in the sytem with
@@ -52,29 +53,6 @@ int omap_usb2_set_comparator(struct phy_companion *comparator)
 }
 EXPORT_SYMBOL_GPL(omap_usb2_set_comparator);
 
-/**
- * omap_usb_phy_power - power on/off the phy using control module reg
- * @phy: struct omap_usb *
- * @on: 0 or 1, based on powering on or off the PHY
- *
- * XXX: Remove this function once control module driver gets merged
- */
-static void omap_usb_phy_power(struct omap_usb *phy, int on)
-{
-	u32 val;
-
-	if (on) {
-		val = readl(phy->control_dev);
-		if (val & PHY_PD) {
-			writel(~PHY_PD, phy->control_dev);
-			/* XXX: add proper documentation for this delay */
-			mdelay(200);
-		}
-	} else {
-		writel(PHY_PD, phy->control_dev);
-	}
-}
-
 static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled)
 {
 	struct omap_usb *phy = phy_to_omapusb(otg->phy);
@@ -124,7 +102,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
 	struct omap_usb *phy = phy_to_omapusb(x);
 
 	if (suspend && !phy->is_suspended) {
-		omap_usb_phy_power(phy, 0);
+		omap_control_usb_phy_power(phy->control_dev, 0);
 		pm_runtime_put_sync(phy->dev);
 		phy->is_suspended = 1;
 	} else if (!suspend && phy->is_suspended) {
@@ -134,7 +112,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend)
 									ret);
 			return ret;
 		}
-		omap_usb_phy_power(phy, 1);
+		omap_control_usb_phy_power(phy->control_dev, 1);
 		phy->is_suspended = 0;
 	}
 
@@ -145,7 +123,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
 {
 	struct omap_usb			*phy;
 	struct usb_otg			*otg;
-	struct resource			*res;
 
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy) {
@@ -166,16 +143,14 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	phy->phy.set_suspend	= omap_usb2_suspend;
 	phy->phy.otg		= otg;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-
-	phy->control_dev = devm_request_and_ioremap(&pdev->dev, res);
-	if (phy->control_dev == NULL) {
-		dev_err(&pdev->dev, "Failed to obtain io memory\n");
-		return -ENXIO;
+	phy->control_dev = omap_get_control_dev();
+	if (IS_ERR(phy->control_dev)) {
+		dev_dbg(&pdev->dev, "Failed to get control device\n");
+		return -ENODEV;
 	}
 
 	phy->is_suspended	= 1;
-	omap_usb_phy_power(phy, 0);
+	omap_control_usb_phy_power(phy->control_dev, 0);
 
 	otg->set_host		= omap_usb_set_host;
 	otg->set_peripheral	= omap_usb_set_peripheral;
diff --git a/include/linux/usb/omap_usb.h b/include/linux/usb/omap_usb.h
index 0ea17f8..3db9b53 100644
--- a/include/linux/usb/omap_usb.h
+++ b/include/linux/usb/omap_usb.h
@@ -25,13 +25,11 @@ struct omap_usb {
 	struct usb_phy		phy;
 	struct phy_companion	*comparator;
 	struct device		*dev;
-	u32 __iomem		*control_dev;
+	struct device		*control_dev;
 	struct clk		*wkupclk;
 	u8			is_suspended:1;
 };
 
-#define	PHY_PD	0x1
-
 #define	phy_to_omapusb(x)	container_of((x), struct omap_usb, phy)
 
 #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE)
-- 
1.7.9.5

^ permalink raw reply related

* [GIT PULL] Renesas pinmux for v3.9
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Olof, Hi Arnd,

please consider the following pinmux enhancements for 3.9.

As discussed previously this series includes changes for shmobile (ARM
based SoC), the SH architecture and pinmux.  It has been agreed by the
maintainers, Paul Mundt, Linus Walleij and myself in conjunction with the
patch-series author Laurent Pinchart and arm-soc co-maintainer Olof
Johansson to take this seies through my renesas tree and thus the arm-soc
tree as a single branch to avoid a complex set of branch dependencies.

These changes have been sitting in next for several weeks now.

I expect there to be a follow-up series of similar complexity
in the 3.10 time-frame. A focus of that series being to add DT bindings.

----------------------------------------------------------------
The following changes since commit 9931faca02c604c22335f5a935a501bb2ace6e20:

  Linux 3.8-rc3 (2013-01-09 18:59:55 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git pfc

for you to fetch changes up to c3323806a67c0c656e27956b7340e37ba6c6968b:

  sh-pfc: Move sh_pfc.h from include/linux/ to driver directory (2013-01-25 09:24:31 +0900)

----------------------------------------------------------------
Laurent Pinchart (80):
      sh: sh7264: Rename CRX0CRX1 mark to match GPIO names
      sh: sh7269: Rename CRX0CRX1(CRX2) marks to match GPIO names
      sh: sh7723: Rename GPIO_FN_SIUOSPD to GPIO_FN_SIUAOSPD
      sh: sh7757: Fix GPIO_FN_ET0_MDIO and GPIO_FN_ET1_MDIO GPIO entries
      sh: sh7786: Fix port E, G and J GPIOs
      sh: sh7786: Fix last GPIO index
      sh: shx3: Fix last GPIO index
      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: Use devm_kzalloc()
      sh-pfc: Use devm_ioremap_nocache()
      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: Use sh_pfc_ namespace prefix through the whole driver
      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
      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
      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: 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

 arch/arm/Kconfig                                   |    1 +
 arch/arm/mach-shmobile/Makefile                    |    8 -
 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/include/cpu-sh4/cpu/sh7723.h               |    2 +-
 arch/sh/include/cpu-sh4/cpu/sh7786.h               |    8 +-
 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                            |    2 +-
 drivers/pinctrl/Makefile                           |    2 +
 drivers/pinctrl/sh-pfc/Kconfig                     |  116 +
 drivers/pinctrl/sh-pfc/Makefile                    |   21 +
 drivers/{sh/pfc => pinctrl/sh-pfc}/core.c          |  355 ++-
 drivers/pinctrl/sh-pfc/core.h                      |   72 +
 drivers/{sh/pfc => pinctrl/sh-pfc}/gpio.c          |  114 +-
 .../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       |  164 +-
 {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 -
 54 files changed, 21897 insertions(+), 21520 deletions(-)
 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 (50%)
 create mode 100644 drivers/pinctrl/sh-pfc/core.h
 rename drivers/{sh/pfc => pinctrl/sh-pfc}/gpio.c (58%)
 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 (75%)
 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

^ permalink raw reply

* [PATCH 01/80] sh: sh7264: Rename CRX0CRX1 mark to match GPIO names
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Rename CRX0CRX1_MARK to CRX0_CRX1_MARK to match the GPIO_FN_CRX0_CRX1
name.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c b/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c
index b055b55..79a0d60 100644
--- a/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c
+++ b/arch/sh/kernel/cpu/sh2a/pinmux-sh7264.c
@@ -505,7 +505,7 @@ enum {
 	PWM2A_MARK, PWM2B_MARK, PWM2C_MARK, PWM2D_MARK,
 	PWM2E_MARK, PWM2F_MARK, PWM2G_MARK, PWM2H_MARK,
 	IERXD_MARK, IETXD_MARK,
-	CRX0CRX1_MARK,
+	CRX0_CRX1_MARK,
 	WDTOVF_MARK,
 
 	CRX0X1_MARK,
@@ -1003,7 +1003,7 @@ static pinmux_enum_t pinmux_data[] = {
 
 	PINMUX_DATA(PJ2_DATA, PJ2MD_000),
 	PINMUX_DATA(CTX1_MARK, PJ2MD_001),
-	PINMUX_DATA(CRX0CRX1_MARK, PJ2MD_010),
+	PINMUX_DATA(CRX0_CRX1_MARK, PJ2MD_010),
 	PINMUX_DATA(CS2_MARK, PJ2MD_011),
 	PINMUX_DATA(SCK0_MARK, PJ2MD_100),
 	PINMUX_DATA(LCD_M_DISP_MARK, PJ2MD_101),
@@ -1246,7 +1246,7 @@ static struct pinmux_gpio pinmux_gpios[] = {
 	PINMUX_GPIO(GPIO_FN_CRX1, CRX1_MARK),
 	PINMUX_GPIO(GPIO_FN_CTX0, CTX0_MARK),
 	PINMUX_GPIO(GPIO_FN_CRX0, CRX0_MARK),
-	PINMUX_GPIO(GPIO_FN_CRX0_CRX1, CRX0CRX1_MARK),
+	PINMUX_GPIO(GPIO_FN_CRX0_CRX1, CRX0_CRX1_MARK),
 
 	/* DMAC */
 	PINMUX_GPIO(GPIO_FN_TEND0, TEND0_MARK),
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 02/80] sh: sh7269: Rename CRX0CRX1(CRX2) marks to match GPIO names
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Rename CRX0CRX1_MARK and CRX0CRX1CRX2_MARK to CRX0_CRX1_MARK and
CRX0_CRX1_CRX2_MARK respectively to match the GPIO_FN_CRX0_CRX1 and
GPIO_FN_CRX0_CRX1_CRX2 GPIO names.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c b/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
index 039e458..1289fd9 100644
--- a/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
+++ b/arch/sh/kernel/cpu/sh2a/pinmux-sh7269.c
@@ -739,8 +739,8 @@ enum {
 	CRX0_MARK, CTX0_MARK,
 	CRX1_MARK, CTX1_MARK,
 	CRX2_MARK, CTX2_MARK,
-	CRX0CRX1_MARK,
-	CRX0CRX1CRX2_MARK,
+	CRX0_CRX1_MARK,
+	CRX0_CRX1_CRX2_MARK,
 	CTX0CTX1CTX2_MARK,
 	CRX1_PJ22_MARK, CTX1_PJ23_MARK,
 	CRX2_PJ20_MARK, CTX2_PJ21_MARK,
@@ -829,7 +829,7 @@ static pinmux_enum_t pinmux_data[] = {
 	PINMUX_DATA(CKE_MARK, PC7MD_001),
 	PINMUX_DATA(RXD7_MARK, PC7MD_010),
 	PINMUX_DATA(CRX1_MARK, PC7MD_011),
-	PINMUX_DATA(CRX0CRX1_MARK, PC7MD_100),
+	PINMUX_DATA(CRX0_CRX1_MARK, PC7MD_100),
 	PINMUX_DATA(IRQ1_PC_MARK, PC7MD_101),
 
 	PINMUX_DATA(PC6_DATA, PC6MD_000),
@@ -1300,7 +1300,7 @@ static pinmux_enum_t pinmux_data[] = {
 	PINMUX_DATA(LCD_TCON5_MARK, PJ22MD_011),
 	PINMUX_DATA(IRQ2_PJ_MARK, PJ22MD_100),
 	PINMUX_DATA(CRX1_MARK, PJ22MD_101),
-	PINMUX_DATA(CRX0CRX1_MARK, PJ22MD_110),
+	PINMUX_DATA(CRX0_CRX1_MARK, PJ22MD_110),
 
 	PINMUX_DATA(PJ21_DATA, PJ21MD_000),
 	PINMUX_DATA(DV_DATA21_MARK, PJ21MD_001),
@@ -1666,8 +1666,8 @@ static struct pinmux_gpio pinmux_gpios[] = {
 	PINMUX_GPIO(GPIO_FN_CRX1, CRX1_MARK),
 	PINMUX_GPIO(GPIO_FN_CTX0, CTX0_MARK),
 	PINMUX_GPIO(GPIO_FN_CRX0, CRX0_MARK),
-	PINMUX_GPIO(GPIO_FN_CRX0_CRX1, CRX0CRX1_MARK),
-	PINMUX_GPIO(GPIO_FN_CRX0_CRX1_CRX2, CRX0CRX1CRX2_MARK),
+	PINMUX_GPIO(GPIO_FN_CRX0_CRX1, CRX0_CRX1_MARK),
+	PINMUX_GPIO(GPIO_FN_CRX0_CRX1_CRX2, CRX0_CRX1_CRX2_MARK),
 
 	/* DMAC */
 	PINMUX_GPIO(GPIO_FN_TEND0, TEND0_MARK),
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 03/80] sh: sh7723: Rename GPIO_FN_SIUOSPD to GPIO_FN_SIUAOSPD
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

The GPIO was incorrectly named. As it has no user in the whole kernel
tree, just rename it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/sh/include/cpu-sh4/cpu/sh7723.h    |    2 +-
 arch/sh/kernel/cpu/sh4a/pinmux-sh7723.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sh/include/cpu-sh4/cpu/sh7723.h b/arch/sh/include/cpu-sh4/cpu/sh7723.h
index 6fae50c..668da89 100644
--- a/arch/sh/include/cpu-sh4/cpu/sh7723.h
+++ b/arch/sh/include/cpu-sh4/cpu/sh7723.h
@@ -184,7 +184,7 @@ enum {
 	/* SIUA */
 	GPIO_FN_SIUAFCK, GPIO_FN_SIUAILR, GPIO_FN_SIUAIBT, GPIO_FN_SIUAISLD,
 	GPIO_FN_SIUAOLR, GPIO_FN_SIUAOBT, GPIO_FN_SIUAOSLD, GPIO_FN_SIUAMCK,
-	GPIO_FN_SIUAISPD, GPIO_FN_SIUOSPD,
+	GPIO_FN_SIUAISPD, GPIO_FN_SIUAOSPD,
 
 	/* SIUB */
 	GPIO_FN_SIUBFCK, GPIO_FN_SIUBILR, GPIO_FN_SIUBIBT, GPIO_FN_SIUBISLD,
diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-sh7723.c b/arch/sh/kernel/cpu/sh4a/pinmux-sh7723.c
index 88bf5ec..2037915 100644
--- a/arch/sh/kernel/cpu/sh4a/pinmux-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-sh7723.c
@@ -1317,7 +1317,7 @@ static struct pinmux_gpio pinmux_gpios[] = {
 	PINMUX_GPIO(GPIO_FN_SIUAOSLD, SIUAOSLD_MARK),
 	PINMUX_GPIO(GPIO_FN_SIUAMCK, SIUAMCK_MARK),
 	PINMUX_GPIO(GPIO_FN_SIUAISPD, SIUAISPD_MARK),
-	PINMUX_GPIO(GPIO_FN_SIUOSPD, SIUAOSPD_MARK),
+	PINMUX_GPIO(GPIO_FN_SIUAOSPD, SIUAOSPD_MARK),
 
 	/* SIUB */
 	PINMUX_GPIO(GPIO_FN_SIUBFCK, SIUBFCK_MARK),
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 04/80] sh: sh7757: Fix GPIO_FN_ET0_MDIO and GPIO_FN_ET1_MDIO GPIO entries
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

The GPIO_FN_ET0_MDIO and GPIO_FN_ET1_MDIO GPIO entries incorrectly
reference the ET0_MDC_MARK and ET1_MDC_MARK marks instead of the
ET0_MDIO_MARK and ET1_MDIO_MARK marks. Fix them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c b/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c
index 4c74bd0..4a2736d 100644
--- a/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c
@@ -1376,9 +1376,9 @@ static struct pinmux_gpio pinmux_gpios[] = {
 	PINMUX_GPIO(GPIO_FN_WE1, WE1_MARK),
 	PINMUX_GPIO(GPIO_FN_RDY, RDY_MARK),
 	PINMUX_GPIO(GPIO_FN_ET0_MDC, ET0_MDC_MARK),
-	PINMUX_GPIO(GPIO_FN_ET0_MDIO, ET0_MDC_MARK),
+	PINMUX_GPIO(GPIO_FN_ET0_MDIO, ET0_MDIO_MARK),
 	PINMUX_GPIO(GPIO_FN_ET1_MDC, ET1_MDC_MARK),
-	PINMUX_GPIO(GPIO_FN_ET1_MDIO, ET1_MDC_MARK),
+	PINMUX_GPIO(GPIO_FN_ET1_MDIO, ET1_MDIO_MARK),
 
 	/* PTB (mobule: INTC, ONFI, TMU) */
 	PINMUX_GPIO(GPIO_FN_IRQ15, IRQ15_MARK),
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 05/80] sh: sh7786: Fix port E, G and J GPIOs
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

The port E, G and J GPIOs don't match the SoC datasheet (they seem to
have been copied from the SH7785). Fix them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/sh/include/cpu-sh4/cpu/sh7786.h    |    8 +++-----
 arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c |    4 ++--
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/sh/include/cpu-sh4/cpu/sh7786.h b/arch/sh/include/cpu-sh4/cpu/sh7786.h
index 977862f..0df09e6 100644
--- a/arch/sh/include/cpu-sh4/cpu/sh7786.h
+++ b/arch/sh/include/cpu-sh4/cpu/sh7786.h
@@ -32,16 +32,14 @@ enum {
 	GPIO_PD3, GPIO_PD2, GPIO_PD1, GPIO_PD0,
 
 	/* PE */
-	GPIO_PE5, GPIO_PE4, GPIO_PE3, GPIO_PE2,
-	GPIO_PE1, GPIO_PE0,
+	GPIO_PE7, GPIO_PE6,
 
 	/* PF */
 	GPIO_PF7, GPIO_PF6, GPIO_PF5, GPIO_PF4,
 	GPIO_PF3, GPIO_PF2, GPIO_PF1, GPIO_PF0,
 
 	/* PG */
-	GPIO_PG7, GPIO_PG6, GPIO_PG5, GPIO_PG4,
-	GPIO_PG3, GPIO_PG2, GPIO_PG1, GPIO_PG0,
+	GPIO_PG7, GPIO_PG6, GPIO_PG5,
 
 	/* PH */
 	GPIO_PH7, GPIO_PH6, GPIO_PH5, GPIO_PH4,
@@ -49,7 +47,7 @@ enum {
 
 	/* PJ */
 	GPIO_PJ7, GPIO_PJ6, GPIO_PJ5, GPIO_PJ4,
-	GPIO_PJ3, GPIO_PJ2, GPIO_PJ1, GPIO_PJ0,
+	GPIO_PJ3, GPIO_PJ2, GPIO_PJ1,
 
 	/* DU */
 	GPIO_FN_DCLKIN, GPIO_FN_DCLKOUT, GPIO_FN_ODDF,
diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c b/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c
index 4229e07..c24a777 100644
--- a/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c
@@ -468,8 +468,8 @@ static struct pinmux_gpio pinmux_gpios[] = {
 	PINMUX_GPIO(GPIO_PD0, PD0_DATA),
 
 	/* PE */
-	PINMUX_GPIO(GPIO_PE5, PE7_DATA),
-	PINMUX_GPIO(GPIO_PE4, PE6_DATA),
+	PINMUX_GPIO(GPIO_PE7, PE7_DATA),
+	PINMUX_GPIO(GPIO_PE6, PE6_DATA),
 
 	/* PF */
 	PINMUX_GPIO(GPIO_PF7, PF7_DATA),
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 06/80] sh: sh7786: Fix last GPIO index
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

A careless look at the code shows that the last entry in the
pinmux_gpios seems to be GPIO_FN_FSE. However, entries are ordered by
the GPIO number, as the PINMUX_GPIO macro is expended to an indexed
array initializer. The last entry in the array is thus GPIO_FN_IRL4. Set
the pinmux_info last_gpio field accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c b/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c
index c24a777..60df99c 100644
--- a/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-sh7786.c
@@ -825,7 +825,7 @@ static struct pinmux_info sh7786_pinmux_info = {
 	.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 
 	.first_gpio = GPIO_PA7,
-	.last_gpio = GPIO_FN_FSE,
+	.last_gpio = GPIO_FN_IRL4,
 
 	.gpios = pinmux_gpios,
 	.cfg_regs = pinmux_config_regs,
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 07/80] sh: shx3: Fix last GPIO index
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

A careless look at the code shows that the last entry in the
pinmux_gpios seems to be GPIO_FN_IRQOUT. However, entries are ordered by
the GPIO number, as the PINMUX_GPIO macro is expended to an indexed
array initializer. The last entry in the array is thus GPIO_FN_STATUS0.
Set the pinmux_info last_gpio field accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/sh/kernel/cpu/sh4a/pinmux-shx3.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-shx3.c b/arch/sh/kernel/cpu/sh4a/pinmux-shx3.c
index aaa5338..2ebb983 100644
--- a/arch/sh/kernel/cpu/sh4a/pinmux-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-shx3.c
@@ -572,7 +572,7 @@ static struct pinmux_info shx3_pinmux_info = {
 	.mark		= { PINMUX_MARK_BEGIN,     PINMUX_MARK_END },
 	.function	= { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
 	.first_gpio	= GPIO_PA7,
-	.last_gpio	= GPIO_FN_IRQOUT,
+	.last_gpio	= GPIO_FN_STATUS0,
 	.gpios		= shx3_pinmux_gpios,
 	.gpio_data	= shx3_pinmux_data,
 	.gpio_data_size	= ARRAY_SIZE(shx3_pinmux_data),
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 08/80] sh-pfc: Split platform data from the sh_pfc structure
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 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 6a24f07..7597a02 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 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 4109b76..3a2c77d 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;
 }
@@ -356,7 +356,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->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);
@@ -375,9 +375,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->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 */
@@ -408,7 +408,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->gpios + i;
+		struct pinmux_gpio *gpio = pfc->pdata->gpios + i;
 
 		if ((gpio->flags & PINMUX_FLAG_TYPE) == PINMUX_TYPE_FUNCTION)
 			pmx->functions[fn++] = gpio;
@@ -444,9 +444,10 @@ static int 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.10.4

^ permalink raw reply related

* [PATCH 09/80] sh-pfc: Move private definitions and declarations to private header
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 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 7597a02..565b366 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 3a2c77d..5801a56 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.10.4

^ permalink raw reply related

* [PATCH 10/80] sh-pfc: Merge PFC core and pinctrl
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 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 5801a56..6f0f58b 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>
@@ -521,7 +521,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.10.4

^ permalink raw reply related

* [PATCH 11/80] sh-pfc: Merge PFC core and gpio
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 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..5410996 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, Laurent Pinchart");
+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 565b366..d8b0c74 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 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 sh_pfc_gpio_remove(struct platform_device *pdev)
+int 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 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		= 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.10.4

^ permalink raw reply related

* [PATCH 12/80] sh-pfc: Move platform device and driver to the core
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 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 5410996..6d162e6 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 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		= 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, Laurent Pinchart");
 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 d8b0c74..a32ea80 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 6f0f58b..2fc8731 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);
@@ -421,28 +418,31 @@ static int sh_pfc_map_functions(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
 	return 0;
 }
 
-static int 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;
 	}
 
@@ -451,79 +451,29 @@ static int 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 sh_pfc_pinctrl_remove(struct platform_device *pdev)
+int 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		= 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.10.4

^ permalink raw reply related

* [PATCH 13/80] sh-pfc: Use devm_kzalloc()
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Replace probe-time kmalloc()/kzalloc() calls with devm_kzalloc() and get
rid of the corresponding kfree() calls.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/core.c    |   20 +++++++-------------
 drivers/sh/pfc/gpio.c    |    8 +++-----
 drivers/sh/pfc/pinctrl.c |   31 +++++++++----------------------
 3 files changed, 19 insertions(+), 40 deletions(-)

diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 6d162e6..5491902 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -33,9 +33,6 @@ static void pfc_iounmap(struct sh_pfc *pfc)
 	for (k = 0; k < pfc->pdata->num_resources; k++)
 		if (pfc->window[k].virt)
 			iounmap(pfc->window[k].virt);
-
-	kfree(pfc->window);
-	pfc->window = NULL;
 }
 
 static int pfc_ioremap(struct sh_pfc *pfc)
@@ -46,10 +43,10 @@ static int pfc_ioremap(struct sh_pfc *pfc)
 	if (!pfc->pdata->num_resources)
 		return 0;
 
-	pfc->window = kzalloc(pfc->pdata->num_resources * sizeof(*pfc->window),
-			      GFP_NOWAIT);
+	pfc->window = devm_kzalloc(pfc->dev, pfc->pdata->num_resources *
+				   sizeof(*pfc->window), GFP_NOWAIT);
 	if (!pfc->window)
-		goto err1;
+		return -ENOMEM;
 
 	for (k = 0; k < pfc->pdata->num_resources; k++) {
 		res = pfc->pdata->resource + k;
@@ -58,16 +55,13 @@ static int pfc_ioremap(struct sh_pfc *pfc)
 		pfc->window[k].size = resource_size(res);
 		pfc->window[k].virt = ioremap_nocache(res->start,
 							 resource_size(res));
-		if (!pfc->window[k].virt)
-			goto err2;
+		if (!pfc->window[k].virt) {
+			pfc_iounmap(pfc);
+			return -ENOMEM;
+		}
 	}
 
 	return 0;
-
-err2:
-	pfc_iounmap(pfc);
-err1:
-	return -1;
 }
 
 static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index a32ea80..37493e5 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -11,6 +11,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME " gpio: " fmt
 
+#include <linux/device.h>
 #include <linux/init.h>
 #include <linux/gpio.h>
 #include <linux/slab.h>
@@ -143,7 +144,7 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
 	struct sh_pfc_chip *chip;
 	int ret;
 
-	chip = kzalloc(sizeof(struct sh_pfc_chip), GFP_KERNEL);
+	chip = devm_kzalloc(pfc->dev, sizeof(*chip), GFP_KERNEL);
 	if (unlikely(!chip))
 		return -ENOMEM;
 
@@ -152,10 +153,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
 	sh_pfc_gpio_setup(chip);
 
 	ret = gpiochip_add(&chip->gpio_chip);
-	if (unlikely(ret < 0)) {
-		kfree(chip);
+	if (unlikely(ret < 0))
 		return ret;
-	}
 
 	pfc->gpio = chip;
 
@@ -175,7 +174,6 @@ int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc)
 	if (unlikely(ret < 0))
 		return ret;
 
-	kfree(chip);
 	pfc->gpio = NULL;
 	return 0;
 }
diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index 2fc8731..b3dbefd 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -11,6 +11,7 @@
 #define DRV_NAME "sh-pfc"
 #define pr_fmt(fmt) KBUILD_MODNAME " pinctrl: " fmt
 
+#include <linux/device.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/sh_pfc.h>
@@ -357,8 +358,8 @@ static int sh_pfc_map_gpios(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
 
 	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);
+	pmx->pads = devm_kzalloc(pfc->dev, sizeof(*pmx->pads) * pmx->nr_pads,
+				 GFP_KERNEL);
 	if (unlikely(!pmx->pads)) {
 		pmx->nr_pads = 0;
 		return -ENOMEM;
@@ -399,8 +400,8 @@ static int sh_pfc_map_functions(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
 	unsigned long flags;
 	int i, fn;
 
-	pmx->functions = kzalloc(pmx->nr_functions * sizeof(void *),
-				 GFP_KERNEL);
+	pmx->functions = devm_kzalloc(pfc->dev, pmx->nr_functions *
+				      sizeof(*pmx->functions), GFP_KERNEL);
 	if (unlikely(!pmx->functions))
 		return -ENOMEM;
 
@@ -423,7 +424,7 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
 	struct sh_pfc_pinctrl *pmx;
 	int ret;
 
-	pmx = kzalloc(sizeof(struct sh_pfc_pinctrl), GFP_KERNEL);
+	pmx = devm_kzalloc(pfc->dev, sizeof(*pmx), GFP_KERNEL);
 	if (unlikely(!pmx))
 		return -ENOMEM;
 
@@ -438,13 +439,11 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
 
 	ret = sh_pfc_map_functions(pfc, pmx);
 	if (unlikely(ret != 0))
-		goto free_pads;
+		return ret;
 
 	pmx->pctl = pinctrl_register(&sh_pfc_pinctrl_desc, pfc->dev, pmx);
-	if (IS_ERR(pmx->pctl)) {
-		ret = PTR_ERR(pmx->pctl);
-		goto free_functions;
-	}
+	if (IS_ERR(pmx->pctl))
+		return PTR_ERR(pmx->pctl);
 
 	sh_pfc_gpio_range.npins = pfc->pdata->last_gpio
 				- pfc->pdata->first_gpio + 1;
@@ -454,14 +453,6 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
 	pinctrl_add_gpio_range(pmx->pctl, &sh_pfc_gpio_range);
 
 	return 0;
-
-free_functions:
-	kfree(pmx->functions);
-free_pads:
-	kfree(pmx->pads);
-	kfree(pmx);
-
-	return ret;
 }
 
 int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc)
@@ -470,10 +461,6 @@ int sh_pfc_unregister_pinctrl(struct sh_pfc *pfc)
 
 	pinctrl_unregister(pmx->pctl);
 
-	kfree(pmx->functions);
-	kfree(pmx->pads);
-	kfree(pmx);
-
 	pfc->pinctrl = NULL;
 	return 0;
 }
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 14/80] sh-pfc: Use devm_ioremap_nocache()
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Replace probe-time ioremap_nocache() call with devm_ioremap_nocache()
and get rid of the corresponding iounmap() call.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/core.c |   25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 5491902..8ec57bd 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -26,15 +26,6 @@
 
 #include "core.h"
 
-static void pfc_iounmap(struct sh_pfc *pfc)
-{
-	int k;
-
-	for (k = 0; k < pfc->pdata->num_resources; k++)
-		if (pfc->window[k].virt)
-			iounmap(pfc->window[k].virt);
-}
-
 static int pfc_ioremap(struct sh_pfc *pfc)
 {
 	struct resource *res;
@@ -53,12 +44,10 @@ static int pfc_ioremap(struct sh_pfc *pfc)
 		WARN_ON(resource_type(res) != IORESOURCE_MEM);
 		pfc->window[k].phys = res->start;
 		pfc->window[k].size = resource_size(res);
-		pfc->window[k].virt = ioremap_nocache(res->start,
-							 resource_size(res));
-		if (!pfc->window[k].virt) {
-			pfc_iounmap(pfc);
+		pfc->window[k].virt = devm_ioremap_nocache(pfc->dev, res->start,
+							   resource_size(res));
+		if (!pfc->window[k].virt)
 			return -ENOMEM;
-		}
 	}
 
 	return 0;
@@ -524,7 +513,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
 	 */
 	ret = sh_pfc_register_pinctrl(pfc);
 	if (unlikely(ret != 0))
-		goto err;
+		return ret;
 
 #ifdef CONFIG_GPIO_SH_PFC
 	/*
@@ -546,10 +535,6 @@ static int sh_pfc_probe(struct platform_device *pdev)
 	pr_info("%s support registered\n", pdata->name);
 
 	return 0;
-
-err:
-	pfc_iounmap(pfc);
-	return ret;
 }
 
 static int sh_pfc_remove(struct platform_device *pdev)
@@ -561,8 +546,6 @@ static int sh_pfc_remove(struct platform_device *pdev)
 #endif
 	sh_pfc_unregister_pinctrl(pfc);
 
-	pfc_iounmap(pfc);
-
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 15/80] sh-pfc: Let the compiler decide whether to inline functions
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/pinctrl.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/sh/pfc/pinctrl.c b/drivers/sh/pfc/pinctrl.c
index b3dbefd..47dbd02 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -116,7 +116,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,
@@ -328,10 +328,8 @@ static struct pinctrl_desc sh_pfc_pinctrl_desc = {
 	.confops	= &sh_pfc_pinconf_ops,
 };
 
-static inline void sh_pfc_map_one_gpio(struct sh_pfc *pfc,
-				       struct sh_pfc_pinctrl *pmx,
-				       struct pinmux_gpio *gpio,
-				       unsigned offset)
+static void 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.10.4

^ permalink raw reply related

* [PATCH 16/80] sh-pfc: Remove check for impossible error condition
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/gpio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index 37493e5..c11c1bb 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -52,7 +52,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);
@@ -63,7 +63,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.10.4

^ permalink raw reply related

* [PATCH 17/80] sh-pfc: Sort headers alphabetically
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/core.c    |   12 ++++++------
 drivers/sh/pfc/gpio.c    |    6 +++---
 drivers/sh/pfc/pinctrl.c |   12 ++++++------
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 8ec57bd..ccf4b7a 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -12,17 +12,17 @@
 #define DRV_NAME "sh-pfc"
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/sh_pfc.h>
-#include <linux/module.h>
+#include <linux/bitops.h>
 #include <linux/err.h>
+#include <linux/errno.h>
 #include <linux/io.h>
-#include <linux/bitops.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/pinctrl/machine.h>
 #include <linux/platform_device.h>
+#include <linux/sh_pfc.h>
+#include <linux/slab.h>
 
 #include "core.h"
 
diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index c11c1bb..a0454f3 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -12,13 +12,13 @@
 #define pr_fmt(fmt) KBUILD_MODNAME " gpio: " fmt
 
 #include <linux/device.h>
-#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 47dbd02..221bde0 100644
--- a/drivers/sh/pfc/pinctrl.c
+++ b/drivers/sh/pfc/pinctrl.c
@@ -12,17 +12,17 @@
 #define pr_fmt(fmt) KBUILD_MODNAME " pinctrl: " fmt
 
 #include <linux/device.h>
+#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 <linux/sh_pfc.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
 
 #include "core.h"
 
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 18/80] sh-pfc: Use sh_pfc_ namespace prefix through the whole driver
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Most of the function and structure names are prefixed by sh_pfc_. Fix
the ones that are not to avoid namespace clashes (especially for
functions that start with gpio_).

Not included in this patch are the platform data structures, those will
be reworked later.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/core.c |  107 ++++++++++++++++++++++++-------------------------
 drivers/sh/pfc/core.h |    4 +-
 2 files changed, 55 insertions(+), 56 deletions(-)

diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index ccf4b7a..1bb38e8 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -26,7 +26,7 @@
 
 #include "core.h"
 
-static int pfc_ioremap(struct sh_pfc *pfc)
+static int sh_pfc_ioremap(struct sh_pfc *pfc)
 {
 	struct resource *res;
 	int k;
@@ -53,10 +53,10 @@ static int pfc_ioremap(struct sh_pfc *pfc)
 	return 0;
 }
 
-static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
-				      unsigned long address)
+static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc,
+					 unsigned long address)
 {
-	struct pfc_window *window;
+	struct sh_pfc_window *window;
 	int k;
 
 	/* scan through physical windows and convert address */
@@ -76,7 +76,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
 	return (void __iomem *)address;
 }
 
-static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
+static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
 {
 	if (enum_id < r->begin)
 		return 0;
@@ -87,8 +87,8 @@ static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
 	return 1;
 }
 
-static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg,
-				       unsigned long reg_width)
+static unsigned long sh_pfc_read_raw_reg(void __iomem *mapped_reg,
+					 unsigned long reg_width)
 {
 	switch (reg_width) {
 	case 8:
@@ -103,9 +103,8 @@ static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg,
 	return 0;
 }
 
-static void gpio_write_raw_reg(void __iomem *mapped_reg,
-			       unsigned long reg_width,
-			       unsigned long data)
+static void sh_pfc_write_raw_reg(void __iomem *mapped_reg,
+				 unsigned long reg_width, unsigned long data)
 {
 	switch (reg_width) {
 	case 8:
@@ -131,7 +130,7 @@ int sh_pfc_read_bit(struct pinmux_data_reg *dr, unsigned long in_pos)
 	pr_debug("read_bit: addr = %lx, pos = %ld, "
 		 "r_width = %ld\n", dr->reg, pos, dr->reg_width);
 
-	return (gpio_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1;
+	return (sh_pfc_read_raw_reg(dr->mapped_reg, dr->reg_width) >> pos) & 1;
 }
 
 void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos,
@@ -150,19 +149,19 @@ void sh_pfc_write_bit(struct pinmux_data_reg *dr, unsigned long in_pos,
 	else
 		clear_bit(pos, &dr->reg_shadow);
 
-	gpio_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow);
+	sh_pfc_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow);
 }
 
-static void config_reg_helper(struct sh_pfc *pfc,
-			      struct pinmux_cfg_reg *crp,
-			      unsigned long in_pos,
-			      void __iomem **mapped_regp,
-			      unsigned long *maskp,
-			      unsigned long *posp)
+static void sh_pfc_config_reg_helper(struct sh_pfc *pfc,
+				     struct pinmux_cfg_reg *crp,
+				     unsigned long in_pos,
+				     void __iomem **mapped_regp,
+				     unsigned long *maskp,
+				     unsigned long *posp)
 {
 	int k;
 
-	*mapped_regp = pfc_phys_to_virt(pfc, crp->reg);
+	*mapped_regp = sh_pfc_phys_to_virt(pfc, crp->reg);
 
 	if (crp->field_width) {
 		*maskp = (1 << crp->field_width) - 1;
@@ -175,30 +174,30 @@ static void config_reg_helper(struct sh_pfc *pfc,
 	}
 }
 
-static int read_config_reg(struct sh_pfc *pfc,
-			   struct pinmux_cfg_reg *crp,
-			   unsigned long field)
+static int sh_pfc_read_config_reg(struct sh_pfc *pfc,
+				  struct pinmux_cfg_reg *crp,
+				  unsigned long field)
 {
 	void __iomem *mapped_reg;
 	unsigned long mask, pos;
 
-	config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
+	sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
 
 	pr_debug("read_reg: addr = %lx, field = %ld, "
 		 "r_width = %ld, f_width = %ld\n",
 		 crp->reg, field, crp->reg_width, crp->field_width);
 
-	return (gpio_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask;
+	return (sh_pfc_read_raw_reg(mapped_reg, crp->reg_width) >> pos) & mask;
 }
 
-static void write_config_reg(struct sh_pfc *pfc,
-			     struct pinmux_cfg_reg *crp,
-			     unsigned long field, unsigned long value)
+static void sh_pfc_write_config_reg(struct sh_pfc *pfc,
+				    struct pinmux_cfg_reg *crp,
+				    unsigned long field, unsigned long value)
 {
 	void __iomem *mapped_reg;
 	unsigned long mask, pos, data;
 
-	config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
+	sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
 
 	pr_debug("write_reg addr = %lx, value = %ld, field = %ld, "
 		 "r_width = %ld, f_width = %ld\n",
@@ -207,24 +206,25 @@ static void write_config_reg(struct sh_pfc *pfc,
 	mask = ~(mask << pos);
 	value = value << pos;
 
-	data = gpio_read_raw_reg(mapped_reg, crp->reg_width);
+	data = sh_pfc_read_raw_reg(mapped_reg, crp->reg_width);
 	data &= mask;
 	data |= value;
 
 	if (pfc->pdata->unlock_reg)
-		gpio_write_raw_reg(pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg),
-				   32, ~data);
+		sh_pfc_write_raw_reg(
+			sh_pfc_phys_to_virt(pfc, pfc->pdata->unlock_reg), 32,
+			~data);
 
-	gpio_write_raw_reg(mapped_reg, crp->reg_width, data);
+	sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data);
 }
 
-static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
+static int sh_pfc_setup_data_reg(struct sh_pfc *pfc, unsigned 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->pdata->data))
+	if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data))
 		return -1;
 
 	k = 0;
@@ -234,7 +234,7 @@ static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
 		if (!data_reg->reg_width)
 			break;
 
-		data_reg->mapped_reg = pfc_phys_to_virt(pfc, data_reg->reg);
+		data_reg->mapped_reg = sh_pfc_phys_to_virt(pfc, data_reg->reg);
 
 		for (n = 0; n < data_reg->reg_width; n++) {
 			if (data_reg->enum_ids[n] == gpiop->enum_id) {
@@ -253,13 +253,13 @@ static int setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
 	return -1;
 }
 
-static void setup_data_regs(struct sh_pfc *pfc)
+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++)
-		setup_data_reg(pfc, k);
+		sh_pfc_setup_data_reg(pfc, k);
 
 	k = 0;
 	while (1) {
@@ -268,8 +268,8 @@ static void setup_data_regs(struct sh_pfc *pfc)
 		if (!drp->reg_width)
 			break;
 
-		drp->reg_shadow = gpio_read_raw_reg(drp->mapped_reg,
-						    drp->reg_width);
+		drp->reg_shadow = sh_pfc_read_raw_reg(drp->mapped_reg,
+						      drp->reg_width);
 		k++;
 	}
 }
@@ -280,7 +280,7 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
 	struct pinmux_gpio *gpiop = &pfc->pdata->gpios[gpio];
 	int k, n;
 
-	if (!enum_in_range(gpiop->enum_id, &pfc->pdata->data))
+	if (!sh_pfc_enum_in_range(gpiop->enum_id, &pfc->pdata->data))
 		return -1;
 
 	k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT;
@@ -290,10 +290,9 @@ int sh_pfc_get_data_reg(struct sh_pfc *pfc, unsigned gpio,
 	return 0;
 }
 
-static int get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
-			  struct pinmux_cfg_reg **crp,
-			  int *fieldp, int *valuep,
-			  unsigned long **cntp)
+static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
+				 struct pinmux_cfg_reg **crp, int *fieldp,
+				 int *valuep, unsigned long **cntp)
 {
 	struct pinmux_cfg_reg *config_reg;
 	unsigned long r_width, f_width, curr_width, ncomb;
@@ -343,8 +342,8 @@ int sh_pfc_gpio_to_enum(struct sh_pfc *pfc, unsigned gpio, int pos,
 	pinmux_enum_t *data = pfc->pdata->gpio_data;
 	int k;
 
-	if (!enum_in_range(enum_id, &pfc->pdata->data)) {
-		if (!enum_in_range(enum_id, &pfc->pdata->mark)) {
+	if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->data)) {
+		if (!sh_pfc_enum_in_range(enum_id, &pfc->pdata->mark)) {
 			pr_err("non data/mark enum_id for gpio %d\n", gpio);
 			return -1;
 		}
@@ -414,7 +413,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->pdata->function);
+		in_range = sh_pfc_enum_in_range(enum_id, &pfc->pdata->function);
 		if (!in_range) {
 			/* not a function enum */
 			if (range) {
@@ -426,7 +425,7 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
 				 * for this case we only allow function enums
 				 * and the enums that match the other range.
 				 */
-				in_range = enum_in_range(enum_id, range);
+				in_range = sh_pfc_enum_in_range(enum_id, range);
 
 				/*
 				 * special case pass through for fixed
@@ -451,19 +450,19 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
 		if (!in_range)
 			continue;
 
-		if (get_config_reg(pfc, enum_id, &cr,
-				   &field, &value, &cntp) != 0)
+		if (sh_pfc_get_config_reg(pfc, enum_id, &cr,
+					  &field, &value, &cntp) != 0)
 			goto out_err;
 
 		switch (cfg_mode) {
 		case GPIO_CFG_DRYRUN:
 			if (!*cntp ||
-			    (read_config_reg(pfc, cr, field) != value))
+			    (sh_pfc_read_config_reg(pfc, cr, field) != value))
 				continue;
 			break;
 
 		case GPIO_CFG_REQ:
-			write_config_reg(pfc, cr, field, value);
+			sh_pfc_write_config_reg(pfc, cr, field, value);
 			*cntp = *cntp + 1;
 			break;
 
@@ -499,14 +498,14 @@ static int sh_pfc_probe(struct platform_device *pdev)
 	pfc->pdata = pdata;
 	pfc->dev = &pdev->dev;
 
-	ret = pfc_ioremap(pfc);
+	ret = sh_pfc_ioremap(pfc);
 	if (unlikely(ret < 0))
 		return ret;
 
 	spin_lock_init(&pfc->lock);
 
 	pinctrl_provide_dummies();
-	setup_data_regs(pfc);
+	sh_pfc_setup_data_regs(pfc);
 
 	/*
 	 * Initialize pinctrl bindings first
diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h
index 1287b3e..d6a40bc 100644
--- a/drivers/sh/pfc/core.h
+++ b/drivers/sh/pfc/core.h
@@ -14,7 +14,7 @@
 #include <linux/sh_pfc.h>
 #include <linux/types.h>
 
-struct pfc_window {
+struct sh_pfc_window {
 	phys_addr_t phys;
 	void __iomem *virt;
 	unsigned long size;
@@ -28,7 +28,7 @@ struct sh_pfc {
 	struct sh_pfc_platform_data *pdata;
 	spinlock_t lock;
 
-	struct pfc_window *window;
+	struct sh_pfc_window *window;
 	struct sh_pfc_chip *gpio;
 	struct sh_pfc_pinctrl *pinctrl;
 };
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 19/80] sh-pfc: Split platform device and platform driver registration
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/core.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 1bb38e8..cd8f09d 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -573,19 +573,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.10.4

^ permalink raw reply related

* [PATCH 20/80] sh-pfc: Support passing resources through platform device
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 drivers/sh/pfc/core.c |   26 +++++++++++++++++++-------
 drivers/sh/pfc/core.h |    2 ++
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index cd8f09d..b2e121d 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -26,21 +26,33 @@
 
 #include "core.h"
 
-static int sh_pfc_ioremap(struct sh_pfc *pfc)
+static int sh_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 = devm_kzalloc(pfc->dev, pfc->pdata->num_resources *
+	pfc->window = devm_kzalloc(pfc->dev, num_resources *
 				   sizeof(*pfc->window), GFP_NOWAIT);
 	if (!pfc->window)
 		return -ENOMEM;
 
-	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);
@@ -60,7 +72,7 @@ static void __iomem *sh_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)
@@ -498,7 +510,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
 	pfc->pdata = pdata;
 	pfc->dev = &pdev->dev;
 
-	ret = sh_pfc_ioremap(pfc);
+	ret = sh_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 d6a40bc..87ae5fd 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 sh_pfc_window *window;
+
 	struct sh_pfc_chip *gpio;
 	struct sh_pfc_pinctrl *pinctrl;
 };
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH 21/80] ARM: shmobile: Select PINCTRL
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/arm/Kconfig |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 67874b8..19c97e5 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -698,6 +698,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.10.4

^ permalink raw reply related

* [PATCH 22/80] ARM: shmobile: r8a7740: Register PFC platform device
From: Simon Horman @ 2013-01-25  2:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1359080696-31489-1-git-send-email-horms+renesas@verge.net.au>

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

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>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/arm/mach-shmobile/pfc-r8a7740.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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.10.4

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox