Re: [PATCH v7 01/17] x86: apl: Add pinctrl driver

2019-12-14 Thread Bin Meng
On Tue, Dec 10, 2019 at 10:06 PM Bin Meng  wrote:
>
> On Mon, Dec 9, 2019 at 8:32 AM Simon Glass  wrote:
> >
> > Add a driver for the Apollo Lake pinctrl. This mostly makes use of the
> > common Intel pinctrl support.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v7:
> > - Drop Glacier Lake code
> > - Fix value of GPIO_28_IRQ
> > - Update Kconfig to avoid using def_bool
> >
> > Changes in v6: None
> > Changes in v5: None
> > Changes in v4:
> > - Allow pinctrl nodes to have subnodes (i.e. GPIO nodes)
> > - Drop GPIO_NUM_PAD_CFG_REGS
> > - Switch over to use pinctrl for pad init/config
> > - Tidy up the header file a little
> > - apollolake -> Apollo Lake
> >
> > Changes in v3:
> > - Add various minor tidy-ups
> > - Fix mixed case in GPIO defines
> > - Rework how pads configuration is defined in TPL and SPL
> > - Use the IRQ uclass instead of ITSS
> >
> > Changes in v2: None
> >
> >  arch/x86/include/asm/arch-apollolake/gpio.h | 485 
> >  drivers/pinctrl/intel/Kconfig   |  16 +-
> >  drivers/pinctrl/intel/Makefile  |   1 +
> >  drivers/pinctrl/intel/pinctrl_apl.c | 192 
> >  4 files changed, 691 insertions(+), 3 deletions(-)
> >  create mode 100644 arch/x86/include/asm/arch-apollolake/gpio.h
> >  create mode 100644 drivers/pinctrl/intel/pinctrl_apl.c
> >
>
> Reviewed-by: Bin Meng 

applied to u-boot-x86/next, thanks!


Re: [PATCH v7 01/17] x86: apl: Add pinctrl driver

2019-12-10 Thread Bin Meng
On Mon, Dec 9, 2019 at 8:32 AM Simon Glass  wrote:
>
> Add a driver for the Apollo Lake pinctrl. This mostly makes use of the
> common Intel pinctrl support.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v7:
> - Drop Glacier Lake code
> - Fix value of GPIO_28_IRQ
> - Update Kconfig to avoid using def_bool
>
> Changes in v6: None
> Changes in v5: None
> Changes in v4:
> - Allow pinctrl nodes to have subnodes (i.e. GPIO nodes)
> - Drop GPIO_NUM_PAD_CFG_REGS
> - Switch over to use pinctrl for pad init/config
> - Tidy up the header file a little
> - apollolake -> Apollo Lake
>
> Changes in v3:
> - Add various minor tidy-ups
> - Fix mixed case in GPIO defines
> - Rework how pads configuration is defined in TPL and SPL
> - Use the IRQ uclass instead of ITSS
>
> Changes in v2: None
>
>  arch/x86/include/asm/arch-apollolake/gpio.h | 485 
>  drivers/pinctrl/intel/Kconfig   |  16 +-
>  drivers/pinctrl/intel/Makefile  |   1 +
>  drivers/pinctrl/intel/pinctrl_apl.c | 192 
>  4 files changed, 691 insertions(+), 3 deletions(-)
>  create mode 100644 arch/x86/include/asm/arch-apollolake/gpio.h
>  create mode 100644 drivers/pinctrl/intel/pinctrl_apl.c
>

Reviewed-by: Bin Meng 


[PATCH v7 01/17] x86: apl: Add pinctrl driver

2019-12-08 Thread Simon Glass
Add a driver for the Apollo Lake pinctrl. This mostly makes use of the
common Intel pinctrl support.

Signed-off-by: Simon Glass 
---

Changes in v7:
- Drop Glacier Lake code
- Fix value of GPIO_28_IRQ
- Update Kconfig to avoid using def_bool

Changes in v6: None
Changes in v5: None
Changes in v4:
- Allow pinctrl nodes to have subnodes (i.e. GPIO nodes)
- Drop GPIO_NUM_PAD_CFG_REGS
- Switch over to use pinctrl for pad init/config
- Tidy up the header file a little
- apollolake -> Apollo Lake

Changes in v3:
- Add various minor tidy-ups
- Fix mixed case in GPIO defines
- Rework how pads configuration is defined in TPL and SPL
- Use the IRQ uclass instead of ITSS

Changes in v2: None

 arch/x86/include/asm/arch-apollolake/gpio.h | 485 
 drivers/pinctrl/intel/Kconfig   |  16 +-
 drivers/pinctrl/intel/Makefile  |   1 +
 drivers/pinctrl/intel/pinctrl_apl.c | 192 
 4 files changed, 691 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/include/asm/arch-apollolake/gpio.h
 create mode 100644 drivers/pinctrl/intel/pinctrl_apl.c

diff --git a/arch/x86/include/asm/arch-apollolake/gpio.h 
b/arch/x86/include/asm/arch-apollolake/gpio.h
new file mode 100644
index 00..10879c168e
--- /dev/null
+++ b/arch/x86/include/asm/arch-apollolake/gpio.h
@@ -0,0 +1,485 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Definitions for the GPIO subsystem on Apollolake
+ *
+ * Copyright (C) 2015 - 2017 Intel Corp.
+ * (Written by Alexandru Gagniuc  for Intel 
Corp.)
+ *
+ * Placed in a separate file since some of these definitions can be used from
+ * assembly code
+ *
+ * Taken from gpio_apl.h in coreboot
+ */
+
+#ifndef _ASM_ARCH_GPIO_H_
+#define _ASM_ARCH_GPIO_H_
+
+/* Port ids */
+#define PID_GPIO_SW0xC0
+#define PID_GPIO_S 0xC2
+#define PID_GPIO_W 0xC7
+#define PID_GPIO_NW0xC4
+#define PID_GPIO_N 0xC5
+#define PID_ITSS   0xD0
+#define PID_RTC0xD1
+
+/*
+ * Miscellaneous Configuration register(MISCCFG). These are community-specific
+ * registers and are meant to house miscellaneous configuration fields per
+ * community. There are 8 GPIO groups: GPP_0 -> GPP_8 (Group 3 is absent)
+ */
+#define GPIO_MISCCFG   0x10 /* Miscellaneous Configuration offset */
+#define  GPIO_GPE_SW_31_0  0 /* SOUTHWEST GPIO#  0 ~ 31 belong to GROUP0 */
+#define  GPIO_GPE_SW_63_32 1 /* SOUTHWEST GPIO# 32 ~ 42 belong to GROUP1 */
+#define  GPIO_GPE_W_31_0   2 /* WEST  GPIO#  0 ~ 25 belong to GROUP2 */
+#define  GPIO_GPE_NW_31_0  4 /* NORTHWEST GPIO#  0 ~ 17 belong to GROUP4 */
+#define  GPIO_GPE_NW_63_32 5 /* NORTHWEST GPIO# 32 ~ 63 belong to GROUP5 */
+#define  GPIO_GPE_NW_95_64 6 /* NORTHWEST GPIO# 64 ~ 76 belong to GROUP6 */
+#define  GPIO_GPE_N_31_0   7 /* NORTH GPIO#  0 ~ 31 belong to GROUP7 */
+#define  GPIO_GPE_N_63_32  8 /* NORTH GPIO# 32 ~ 61 belong to GROUP8 */
+
+#define GPIO_MAX_NUM_PER_GROUP 32
+
+/*
+ * Host Software Pad Ownership Register.
+ * The pins in the community are divided into 3 groups:
+ * GPIO 0 ~ 31, GPIO 32 ~ 63, GPIO 64 ~ 95
+ */
+#define HOSTSW_OWN_REG_0   0x80
+
+#define PAD_CFG_BASE   0x500
+
+#define GPI_INT_STS_0  0x100
+#define GPI_INT_EN_0   0x110
+
+#define GPI_SMI_STS_0  0x140
+#define GPI_SMI_EN_0   0x150
+
+#define NUM_N_PADS (PAD_N(SVID0_CLK) + 1)
+#define NUM_NW_PADS(PAD_NW(GPIO_123) + 1)
+#define NUM_W_PADS (PAD_W(SUSPWRDNACK) + 1)
+#define NUM_SW_PADS(PAD_SW(LPC_FRAMEB) + 1)
+
+#define NUM_N_GPI_REGS \
+   (ALIGN(NUM_N_PADS, GPIO_MAX_NUM_PER_GROUP) / GPIO_MAX_NUM_PER_GROUP)
+
+#define NUM_NW_GPI_REGS\
+   (ALIGN(NUM_NW_PADS, GPIO_MAX_NUM_PER_GROUP) / GPIO_MAX_NUM_PER_GROUP)
+
+#define NUM_W_GPI_REGS \
+   (ALIGN(NUM_W_PADS, GPIO_MAX_NUM_PER_GROUP) / GPIO_MAX_NUM_PER_GROUP)
+
+#define NUM_SW_GPI_REGS\
+   (ALIGN(NUM_SW_PADS, GPIO_MAX_NUM_PER_GROUP) / GPIO_MAX_NUM_PER_GROUP)
+
+/*
+ * Total number of GPI status registers across all GPIO communities in the SOC
+ */
+#define NUM_GPI_STATUS_REGS(NUM_N_GPI_REGS + NUM_NW_GPI_REGS \
+   + NUM_W_GPI_REGS + NUM_SW_GPI_REGS)
+
+/* North community pads */
+#define GPIO_0 0
+#define GPIO_1 1
+#define GPIO_2 2
+#define GPIO_3 3
+#define GPIO_4 4
+#define GPIO_5 5
+#define GPIO_6 6
+#define GPIO_7 7
+#define GPIO_8 8
+#define GPIO_9 9
+#define GPIO_1010
+#define GPIO_1111
+#define GPIO_1212
+#define GPIO_13