Commit 6bd1eb6c authored by Linus Walleij's avatar Linus Walleij
Browse files

Merge tag 'sh-pfc-for-v5.3-tag1' of...

Merge tag 'sh-pfc-for-v5.3-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into devel

pinctrl: sh-pfc: Updates for v5.3

  - Add more checks for pinctrl table validation,
  - Add TPU (Timer Pulse Unit / PWM) pin groups on R-Car H3, M3-W, and
    M3-N,
  - Rework description of pins without GPIO functionality,
  - Small fixes and cleanups.
parents 9d130f91 992968d7
Loading
Loading
Loading
Loading
+50 −10
Original line number Diff line number Diff line
@@ -717,7 +717,7 @@ static int sh_pfc_suspend_init(struct sh_pfc *pfc) { return 0; }
#endif /* CONFIG_PM_SLEEP && CONFIG_ARM_PSCI_FW */

#ifdef DEBUG
static bool is0s(const u16 *enum_ids, unsigned int n)
static bool __init is0s(const u16 *enum_ids, unsigned int n)
{
	unsigned int i;

@@ -728,10 +728,10 @@ static bool is0s(const u16 *enum_ids, unsigned int n)
	return true;
}

static unsigned int sh_pfc_errors;
static unsigned int sh_pfc_warnings;
static unsigned int sh_pfc_errors __initdata = 0;
static unsigned int sh_pfc_warnings __initdata = 0;

static void sh_pfc_check_cfg_reg(const char *drvname,
static void __init sh_pfc_check_cfg_reg(const char *drvname,
					const struct pinmux_cfg_reg *cfg_reg)
{
	unsigned int i, n, rw, fw;
@@ -764,7 +764,7 @@ static void sh_pfc_check_cfg_reg(const char *drvname,
	}
}

static void sh_pfc_check_info(const struct sh_pfc_soc_info *info)
static void __init sh_pfc_check_info(const struct sh_pfc_soc_info *info)
{
	const struct sh_pfc_function *func;
	const char *drvname = info->name;
@@ -773,6 +773,35 @@ static void sh_pfc_check_info(const struct sh_pfc_soc_info *info)

	pr_info("Checking %s\n", drvname);

	/* Check pins */
	for (i = 0; i < info->nr_pins; i++) {
		for (j = 0; j < i; j++) {
			if (!strcmp(info->pins[i].name, info->pins[j].name)) {
				pr_err("%s: pin %s/%s: name conflict\n",
				       drvname, info->pins[i].name,
				       info->pins[j].name);
				sh_pfc_errors++;
			}

			if (info->pins[i].pin != (u16)-1 &&
			    info->pins[i].pin == info->pins[j].pin) {
				pr_err("%s: pin %s/%s: pin %u conflict\n",
				       drvname, info->pins[i].name,
				       info->pins[j].name, info->pins[i].pin);
				sh_pfc_errors++;
			}

			if (info->pins[i].enum_id &&
			    info->pins[i].enum_id == info->pins[j].enum_id) {
				pr_err("%s: pin %s/%s: enum_id %u conflict\n",
				       drvname, info->pins[i].name,
				       info->pins[j].name,
				       info->pins[i].enum_id);
				sh_pfc_errors++;
			}
		}
	}

	/* Check groups and functions */
	refcnts = kcalloc(info->nr_groups, sizeof(*refcnts), GFP_KERNEL);
	if (!refcnts)
@@ -780,9 +809,15 @@ static void sh_pfc_check_info(const struct sh_pfc_soc_info *info)

	for (i = 0; i < info->nr_functions; i++) {
		func = &info->functions[i];
		if (!func->name) {
			pr_err("%s: empty function %u\n", drvname, i);
			sh_pfc_errors++;
			continue;
		}
		for (j = 0; j < func->nr_groups; j++) {
			for (k = 0; k < info->nr_groups; k++) {
				if (!strcmp(func->groups[j],
				if (info->groups[k].name &&
				    !strcmp(func->groups[j],
					    info->groups[k].name)) {
					refcnts[k]++;
					break;
@@ -798,12 +833,17 @@ static void sh_pfc_check_info(const struct sh_pfc_soc_info *info)
	}

	for (i = 0; i < info->nr_groups; i++) {
		if (!info->groups[i].name) {
			pr_err("%s: empty group %u\n", drvname, i);
			sh_pfc_errors++;
			continue;
		}
		if (!refcnts[i]) {
			pr_err("%s: orphan group %s\n", drvname,
			       info->groups[i].name);
			sh_pfc_errors++;
		} else if (refcnts[i] > 1) {
			pr_err("%s: group %s referred by %u functions\n",
			pr_warn("%s: group %s referenced by %u functions\n",
				drvname, info->groups[i].name, refcnts[i]);
			sh_pfc_warnings++;
		}
@@ -816,7 +856,7 @@ static void sh_pfc_check_info(const struct sh_pfc_soc_info *info)
		sh_pfc_check_cfg_reg(drvname, &info->cfg_regs[i]);
}

static void sh_pfc_check_driver(const struct platform_driver *pdrv)
static void __init sh_pfc_check_driver(const struct platform_driver *pdrv)
{
	unsigned int i;

+34 −36
Original line number Diff line number Diff line
@@ -19,6 +19,20 @@
	PORT_1(155, fn, pfx##155, sfx), PORT_1(156, fn, pfx##156, sfx), \
	PORT_1(157, fn, pfx##157, sfx), PORT_1(158, fn, pfx##158, sfx)

#define CPU_ALL_NOGP(fn)		\
	PIN_NOGP(LCD3_B2, "B15", fn),	\
	PIN_NOGP(LCD3_B3, "C15", fn),	\
	PIN_NOGP(LCD3_B4, "D15", fn),	\
	PIN_NOGP(LCD3_B5, "B14", fn),	\
	PIN_NOGP(LCD3_B6, "C14", fn),	\
	PIN_NOGP(LCD3_B7, "D14", fn),	\
	PIN_NOGP(LCD3_G2, "B17", fn),	\
	PIN_NOGP(LCD3_G3, "C17", fn),	\
	PIN_NOGP(LCD3_G4, "D17", fn),	\
	PIN_NOGP(LCD3_G5, "B16", fn),	\
	PIN_NOGP(LCD3_G6, "C16", fn),	\
	PIN_NOGP(LCD3_G7, "D16", fn)

enum {
	PINMUX_RESERVED = 0,

@@ -218,10 +232,13 @@ enum {
	PINMUX_MARK_END,
};

/* Pin numbers for pins without a corresponding GPIO port number are computed
 * from the row and column numbers with a 1000 offset to avoid collisions with
 * GPIO port numbers. */
#define PIN_NUMBER(row, col)            (1000+((row)-1)*23+(col)-1)
/*
 * Pins not associated with a GPIO port.
 */
enum {
	PORT_ASSIGN_LAST(),
	NOGP_ALL(),
};

/* Expand to a list of sh_pfc_pin entries (named PORT#).
 * NOTE: No config are recorded since the driver do not handle pinconf. */
@@ -230,20 +247,7 @@ enum {

static const struct sh_pfc_pin pinmux_pins[] = {
	PINMUX_EMEV_GPIO_ALL(),

	/* Pins not associated with a GPIO port */
	SH_PFC_PIN_NAMED(2, 14, B14),
	SH_PFC_PIN_NAMED(2, 15, B15),
	SH_PFC_PIN_NAMED(2, 16, B16),
	SH_PFC_PIN_NAMED(2, 17, B17),
	SH_PFC_PIN_NAMED(3, 14, C14),
	SH_PFC_PIN_NAMED(3, 15, C15),
	SH_PFC_PIN_NAMED(3, 16, C16),
	SH_PFC_PIN_NAMED(3, 17, C17),
	SH_PFC_PIN_NAMED(4, 14, D14),
	SH_PFC_PIN_NAMED(4, 15, D15),
	SH_PFC_PIN_NAMED(4, 16, D16),
	SH_PFC_PIN_NAMED(4, 17, D17),
	PINMUX_NOGP_ALL(),
};

/* Expand to a list of name_DATA, name_FN marks */
@@ -829,12 +833,10 @@ static const unsigned int lcd3_rgb888_pins[] = {
	/* R[0:7], G[0:7], B[0:7] */
	32, 33, 34, 35,
	36, 37, 38, 39,
	40, 41, PIN_NUMBER(2, 17), PIN_NUMBER(3, 17),
	PIN_NUMBER(4, 17), PIN_NUMBER(2, 16), PIN_NUMBER(3, 16),
	PIN_NUMBER(4, 16),
	42, 43, PIN_NUMBER(2, 15), PIN_NUMBER(3, 15),
	PIN_NUMBER(4, 15), PIN_NUMBER(2, 14), PIN_NUMBER(3, 14),
	PIN_NUMBER(4, 14)
	40, 41, PIN_LCD3_G2, PIN_LCD3_G3,
	PIN_LCD3_G4, PIN_LCD3_G5, PIN_LCD3_G6, PIN_LCD3_G7,
	42, 43, PIN_LCD3_B2, PIN_LCD3_B3,
	PIN_LCD3_B4, PIN_LCD3_B5, PIN_LCD3_B6, PIN_LCD3_B7
};
static const unsigned int lcd3_rgb888_mux[] = {
	LCD3_R0_MARK, LCD3_R1_MARK, LCD3_R2_MARK, LCD3_R3_MARK,
@@ -850,12 +852,10 @@ static const unsigned int yuv3_pins[] = {
	/* CLK_O, HS, VS, DE */
	18, 21, 22, 23,
	/* YUV3_D[0:15] */
	40, 41, PIN_NUMBER(2, 17), PIN_NUMBER(3, 17),
	PIN_NUMBER(4, 17), PIN_NUMBER(2, 16), PIN_NUMBER(3, 16),
	PIN_NUMBER(4, 16),
	42, 43, PIN_NUMBER(2, 15), PIN_NUMBER(3, 15),
	PIN_NUMBER(4, 15), PIN_NUMBER(2, 14), PIN_NUMBER(3, 14),
	PIN_NUMBER(4, 14),
	40, 41, PIN_LCD3_G2, PIN_LCD3_G3,
	PIN_LCD3_G4, PIN_LCD3_G5, PIN_LCD3_G6, PIN_LCD3_G7,
	42, 43, PIN_LCD3_B2, PIN_LCD3_B3,
	PIN_LCD3_B4, PIN_LCD3_B5, PIN_LCD3_B6, PIN_LCD3_B7,
};
static const unsigned int yuv3_mux[] = {
	YUV3_CLK_O_MARK, YUV3_HS_MARK, YUV3_VS_MARK, YUV3_DE_MARK,
@@ -972,12 +972,10 @@ static const unsigned int tp33_pins[] = {
	/* CLK, CTRL */
	38, 39,
	/* TP33_DATA[0:15] */
	40, 41, PIN_NUMBER(2, 17), PIN_NUMBER(3, 17),
	PIN_NUMBER(4, 17), PIN_NUMBER(2, 16), PIN_NUMBER(3, 16),
	PIN_NUMBER(4, 16),
	42, 43, PIN_NUMBER(2, 15), PIN_NUMBER(3, 15),
	PIN_NUMBER(4, 15), PIN_NUMBER(2, 14), PIN_NUMBER(3, 14),
	PIN_NUMBER(4, 14),
	40, 41, PIN_LCD3_G2, PIN_LCD3_G3,
	PIN_LCD3_G4, PIN_LCD3_G5, PIN_LCD3_G6, PIN_LCD3_G7,
	42, 43, PIN_LCD3_B2, PIN_LCD3_B3,
	PIN_LCD3_B4, PIN_LCD3_B5, PIN_LCD3_B6, PIN_LCD3_B7,
};
static const unsigned int tp33_mux[] = {
	TP33_CLK_MARK, TP33_CTRL_MARK,
+1 −1
Original line number Diff line number Diff line
@@ -1252,7 +1252,7 @@ static const u16 pinmux_data[] = {

#define __O	(SH_PFC_PIN_CFG_OUTPUT)
#define __IO	(SH_PFC_PIN_CFG_INPUT | SH_PFC_PIN_CFG_OUTPUT)
#define __PUD	(SH_PFC_PIN_CFG_PULL_DOWN | SH_PFC_PIN_CFG_PULL_UP)
#define __PUD	(SH_PFC_PIN_CFG_PULL_UP_DOWN)

#define R8A73A4_PIN_IO_PU_PD(pin)       SH_PFC_PIN_CFG(pin, __IO | __PUD)
#define R8A73A4_PIN_O(pin)              SH_PFC_PIN_CFG(pin, __O)
+1 −1
Original line number Diff line number Diff line
@@ -1515,7 +1515,7 @@ static const u16 pinmux_data[] = {
#define __IO		(SH_PFC_PIN_CFG_INPUT | SH_PFC_PIN_CFG_OUTPUT)
#define __PD		(SH_PFC_PIN_CFG_PULL_DOWN)
#define __PU		(SH_PFC_PIN_CFG_PULL_UP)
#define __PUD		(SH_PFC_PIN_CFG_PULL_DOWN | SH_PFC_PIN_CFG_PULL_UP)
#define __PUD		(SH_PFC_PIN_CFG_PULL_UP_DOWN)

#define R8A7740_PIN_I_PD(pin)		SH_PFC_PIN_CFG(pin, __I | __PD)
#define R8A7740_PIN_I_PU(pin)		SH_PFC_PIN_CFG(pin, __I | __PU)
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@

#include "sh_pfc.h"

#define CPU_ALL_PORT(fn, sfx)						\
#define CPU_ALL_GP(fn, sfx)						\
	PORT_GP_4(0, fn, sfx),						\
	PORT_GP_1(0, 4, fn, sfx),					\
	PORT_GP_CFG_1(0,  5, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),	\
Loading