* [PATCH 01/10] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI
[not found] <1457774112-16958-1-git-send-email-wsa@the-dreams.de>
@ 2016-03-12 9:15 ` Wolfram Sang
2016-03-14 9:47 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2016-03-12 9:15 UTC (permalink / raw)
To: linux-renesas-soc
Cc: Wolfram Sang, linux-mmc, Dirk Behme, Ben Hutchings, linux-gpio
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
All the SHDIs can operate with either 3.3V or 1.8V signals, depending
on negotiation with the card.
Implement the {get,set}_io_voltage operations and set the related
capability flag for the associated pins.
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-gpio@vger.kernel.org
---
Changes since RFC:
* Don't export sh_pfc_phys_to_virt but use pfc->windows->virt directly.
drivers/pinctrl/sh-pfc/pfc-r8a7790.c | 54 +++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
index 0f4d48f9400ba0..eed8daa464cc1e 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
@@ -21,16 +21,21 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <linux/io.h>
#include <linux/kernel.h>
#include "core.h"
#include "sh_pfc.h"
+/*
+ * All pins assigned to GPIO bank 3 can be used for SD interfaces in
+ * which case they support both 3.3V and 1.8V signalling.
+ */
#define CPU_ALL_PORT(fn, sfx) \
PORT_GP_32(0, fn, sfx), \
PORT_GP_30(1, fn, sfx), \
PORT_GP_30(2, fn, sfx), \
- PORT_GP_32(3, fn, sfx), \
+ PORT_GP_CFG_32(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
PORT_GP_32(4, fn, sfx), \
PORT_GP_32(5, fn, sfx)
@@ -4691,6 +4696,47 @@ static const char * const vin3_groups[] = {
"vin3_clk",
};
+#define IOCTRL6 0x8c
+
+static int r8a7790_get_io_voltage(struct sh_pfc *pfc, unsigned int pin)
+{
+ u32 data, mask;
+
+ if (WARN(pin < RCAR_GP_PIN(3, 0) || pin > RCAR_GP_PIN(3, 31), "invalid pin %#x", pin))
+ return -EINVAL;
+
+ data = ioread32(pfc->windows->virt + IOCTRL6),
+ /* Bits in IOCTRL6 are numbered in opposite order to pins */
+ mask = 0x80000000 >> (pin & 0x1f);
+
+ return (data & mask) ? 3300 : 1800;
+}
+
+static int r8a7790_set_io_voltage(struct sh_pfc *pfc, unsigned int pin, u16 mV)
+{
+ u32 data, mask;
+
+ if (WARN(pin < RCAR_GP_PIN(3, 0) || pin > RCAR_GP_PIN(3, 31), "invalid pin %#x", pin))
+ return -EINVAL;
+
+ if (mV != 1800 && mV != 3300)
+ return -EINVAL;
+
+ data = ioread32(pfc->windows->virt + IOCTRL6);
+ /* Bits in IOCTRL6 are numbered in opposite order to pins */
+ mask = 0x80000000 >> (pin & 0x1f);
+
+ if (mV == 3300)
+ data |= mask;
+ else
+ data &= ~mask;
+
+ iowrite32(~data, pfc->windows->virt); /* unlock reg */
+ iowrite32(data, pfc->windows->virt + IOCTRL6);
+
+ return 0;
+}
+
static const struct sh_pfc_function pinmux_functions[] = {
SH_PFC_FUNCTION(audio_clk),
SH_PFC_FUNCTION(avb),
@@ -5690,8 +5736,14 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
{ },
};
+static const struct sh_pfc_soc_operations pinmux_ops = {
+ .get_io_voltage = r8a7790_get_io_voltage,
+ .set_io_voltage = r8a7790_set_io_voltage,
+};
+
const struct sh_pfc_soc_info r8a7790_pinmux_info = {
.name = "r8a77900_pfc",
+ .ops = &pinmux_ops,
.unlock_reg = 0xe6060000, /* PMMR */
.function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 01/10] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI
2016-03-12 9:15 ` [PATCH 01/10] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI Wolfram Sang
@ 2016-03-14 9:47 ` Geert Uytterhoeven
2016-03-22 8:35 ` Wolfram Sang
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2016-03-14 9:47 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-renesas-soc, Linux MMC List, Dirk Behme, Ben Hutchings,
linux-gpio@vger.kernel.org
On Sat, Mar 12, 2016 at 10:15 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
>
> All the SHDIs can operate with either 3.3V or 1.8V signals, depending
> on negotiation with the card.
>
> Implement the {get,set}_io_voltage operations and set the related
> capability flag for the associated pins.
>
> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: linux-gpio@vger.kernel.org
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 01/10] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI
2016-03-14 9:47 ` Geert Uytterhoeven
@ 2016-03-22 8:35 ` Wolfram Sang
2016-03-22 8:44 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2016-03-22 8:35 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: linux-renesas-soc, Linux MMC List, Dirk Behme, Ben Hutchings,
linux-gpio@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 722 bytes --]
On Mon, Mar 14, 2016 at 10:47:23AM +0100, Geert Uytterhoeven wrote:
> On Sat, Mar 12, 2016 at 10:15 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> > From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> >
> > All the SHDIs can operate with either 3.3V or 1.8V signals, depending
> > on negotiation with the card.
> >
> > Implement the {get,set}_io_voltage operations and set the related
> > capability flag for the associated pins.
> >
> > Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Cc: linux-gpio@vger.kernel.org
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
So, can this be picked up already?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 01/10] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI
2016-03-22 8:35 ` Wolfram Sang
@ 2016-03-22 8:44 ` Geert Uytterhoeven
0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2016-03-22 8:44 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-renesas-soc, Linux MMC List, Dirk Behme, Ben Hutchings,
linux-gpio@vger.kernel.org
Hi Wolfram,
On Tue, Mar 22, 2016 at 9:35 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> On Mon, Mar 14, 2016 at 10:47:23AM +0100, Geert Uytterhoeven wrote:
>> On Sat, Mar 12, 2016 at 10:15 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
>> > From: Wolfram Sang <wsa+renesas@sang-engineering.com>
>> >
>> > All the SHDIs can operate with either 3.3V or 1.8V signals, depending
>> > on negotiation with the card.
>> >
>> > Implement the {get,set}_io_voltage operations and set the related
>> > capability flag for the associated pins.
>> >
>> > Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
>> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
>> > Cc: linux-gpio@vger.kernel.org
>>
>> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> So, can this be picked up already?
I'll add it to sh-pfc-for-v4.7, and to next renesas-drivers.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-22 8:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1457774112-16958-1-git-send-email-wsa@the-dreams.de>
2016-03-12 9:15 ` [PATCH 01/10] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI Wolfram Sang
2016-03-14 9:47 ` Geert Uytterhoeven
2016-03-22 8:35 ` Wolfram Sang
2016-03-22 8:44 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).