* [PATCH 01/43] gpio: ep93xx: split device in multiple
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
@ 2023-04-24 12:34 ` Nikita Shubin
2023-04-24 12:34 ` [PATCH 34/43] ARM: dts: add device tree for ep93xx Soc Nikita Shubin
` (6 subsequent siblings)
7 siblings, 0 replies; 20+ messages in thread
From: Nikita Shubin @ 2023-04-24 12:34 UTC (permalink / raw)
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Linus Walleij,
Hartley Sweeten, Russell King, Lukasz Majewski,
Bartosz Golaszewski, linux-arm-kernel, linux-kernel, linux-gpio
This prepares ep93xx SOC gpio to convert into device tree driver:
- dropped banks and legacy defines
- split AB IRQ and make it shared
We are relying on IRQ number information A, B ports have single shared
IRQ, while F port have dedicated IRQ for each line.
Also we had to split single ep93xx platform_device into multiple, one
for each port, without this we can't do a full working transition from
legacy platform code into device tree capable. All GPIO_LOOKUP were
change to match new chip namings.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/mach-ep93xx/core.c | 121 +++++++++-
arch/arm/mach-ep93xx/edb93xx.c | 2 +-
arch/arm/mach-ep93xx/ts72xx.c | 4 +-
arch/arm/mach-ep93xx/vision_ep9307.c | 10 +-
drivers/gpio/gpio-ep93xx.c | 323 ++++++++++-----------------
5 files changed, 236 insertions(+), 224 deletions(-)
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 71b113976420..d61c1d2a0843 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -35,6 +35,7 @@
#include <linux/reboot.h>
#include <linux/usb/ohci_pdriver.h>
#include <linux/random.h>
+#include <linux/ioport.h>
#include "hardware.h"
#include <linux/platform_data/video-ep93xx.h>
@@ -139,9 +140,80 @@ EXPORT_SYMBOL_GPL(ep93xx_chip_revision);
/*************************************************************************
* EP93xx GPIO
*************************************************************************/
-static struct resource ep93xx_gpio_resource[] = {
- DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE, 0xcc),
+/* port A */
+static struct resource ep93xx_a_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x10, 0x04, "dir"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x90, 0x1c, "intr"),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB),
+};
+
+static struct platform_device ep93xx_a_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(ep93xx_a_gpio_resources),
+ .resource = ep93xx_a_gpio_resources,
+};
+
+/* port B */
+static struct resource ep93xx_b_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x04, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x14, 0x04, "dir"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0xac, 0x1c, "intr"),
+ DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB),
+};
+
+static struct platform_device ep93xx_b_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(ep93xx_b_gpio_resources),
+ .resource = ep93xx_b_gpio_resources,
+};
+
+/* port C */
+static struct resource ep93xx_c_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x08, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x18, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_c_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 2,
+ .num_resources = ARRAY_SIZE(ep93xx_c_gpio_resources),
+ .resource = ep93xx_c_gpio_resources,
+};
+
+/* port D */
+static struct resource ep93xx_d_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x0c, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x1c, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_d_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 3,
+ .num_resources = ARRAY_SIZE(ep93xx_d_gpio_resources),
+ .resource = ep93xx_d_gpio_resources,
+};
+
+/* port E */
+static struct resource ep93xx_e_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x20, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x24, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_e_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 4,
+ .num_resources = ARRAY_SIZE(ep93xx_e_gpio_resources),
+ .resource = ep93xx_e_gpio_resources,
+};
+
+/* port F */
+static struct resource ep93xx_f_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x30, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x34, 0x04, "dir"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x4c, 0x1c, "intr"),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO0MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO1MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO2MUX),
@@ -152,11 +224,34 @@ static struct resource ep93xx_gpio_resource[] = {
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO7MUX),
};
-static struct platform_device ep93xx_gpio_device = {
- .name = "gpio-ep93xx",
- .id = -1,
- .num_resources = ARRAY_SIZE(ep93xx_gpio_resource),
- .resource = ep93xx_gpio_resource,
+static struct platform_device ep93xx_f_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 5,
+ .num_resources = ARRAY_SIZE(ep93xx_f_gpio_resources),
+ .resource = ep93xx_f_gpio_resources,
+};
+
+/* port G */
+static struct resource ep93xx_g_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x38, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x3c, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_g_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 6,
+ .num_resources = ARRAY_SIZE(ep93xx_g_gpio_resources),
+ .resource = ep93xx_g_gpio_resources,
+};
+
+static struct platform_device *ep93xx_gpio_device[] __initdata = {
+ &ep93xx_a_gpio,
+ &ep93xx_b_gpio,
+ &ep93xx_c_gpio,
+ &ep93xx_d_gpio,
+ &ep93xx_e_gpio,
+ &ep93xx_f_gpio,
+ &ep93xx_g_gpio,
};
/*************************************************************************
@@ -335,9 +430,9 @@ static struct gpiod_lookup_table ep93xx_i2c_gpiod_table = {
.dev_id = "i2c-gpio.0",
.table = {
/* Use local offsets on gpiochip/port "G" */
- GPIO_LOOKUP_IDX("G", 1, NULL, 0,
+ GPIO_LOOKUP_IDX("gpio-ep93xx.6", 1, NULL, 0,
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
- GPIO_LOOKUP_IDX("G", 0, NULL, 1,
+ GPIO_LOOKUP_IDX("gpio-ep93xx.6", 0, NULL, 1,
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
},
};
@@ -440,8 +535,8 @@ static struct gpiod_lookup_table ep93xx_leds_gpio_table = {
.dev_id = "leds-gpio",
.table = {
/* Use local offsets on gpiochip/port "E" */
- GPIO_LOOKUP_IDX("E", 0, NULL, 0, GPIO_ACTIVE_HIGH),
- GPIO_LOOKUP_IDX("E", 1, NULL, 1, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.4", 0, NULL, 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.4", 1, NULL, 1, GPIO_ACTIVE_HIGH),
{ }
},
};
@@ -974,6 +1069,7 @@ static struct device __init *ep93xx_init_soc(void)
struct device __init *ep93xx_init_devices(void)
{
struct device *parent;
+ int i;
/* Disallow access to MaverickCrunch initially */
ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA);
@@ -988,7 +1084,8 @@ struct device __init *ep93xx_init_devices(void)
parent = ep93xx_init_soc();
/* Get the GPIO working early, other devices need it */
- platform_device_register(&ep93xx_gpio_device);
+ for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_device); i++)
+ platform_device_register(ep93xx_gpio_device[i]);
amba_device_register(&uart1_device, &iomem_resource);
amba_device_register(&uart2_device, &iomem_resource);
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c
index 4b90899a66e9..c1e880946f72 100644
--- a/arch/arm/mach-ep93xx/edb93xx.c
+++ b/arch/arm/mach-ep93xx/edb93xx.c
@@ -105,7 +105,7 @@ static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
static struct gpiod_lookup_table edb93xx_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
- GPIO_LOOKUP("A", 6, "cs", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio-ep93xx.0", 6, "cs", GPIO_ACTIVE_LOW),
{ },
},
};
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index d3de7283ecb3..0bbdf587c685 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -268,7 +268,7 @@ static struct spi_board_info bk3_spi_board_info[] __initdata = {
static struct gpiod_lookup_table bk3_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
- GPIO_LOOKUP("F", 3, "cs", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio-ep93xx.5", 3, "cs", GPIO_ACTIVE_LOW),
{ },
},
};
@@ -318,7 +318,7 @@ static struct gpiod_lookup_table ts72xx_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
/* DIO_17 */
- GPIO_LOOKUP("F", 2, "cs", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio-ep93xx.5", 2, "cs", GPIO_ACTIVE_LOW),
{ },
},
};
diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c
index 30d9cf3791eb..020223b0be2b 100644
--- a/arch/arm/mach-ep93xx/vision_ep9307.c
+++ b/arch/arm/mach-ep93xx/vision_ep9307.c
@@ -206,9 +206,9 @@ static struct gpiod_lookup_table vision_spi_mmc_gpio_table = {
.dev_id = "mmc_spi.2", /* "mmc_spi @ CS2 */
.table = {
/* Card detect */
- GPIO_LOOKUP_IDX("B", 7, NULL, 0, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.1", 7, NULL, 0, GPIO_ACTIVE_LOW),
/* Write protect */
- GPIO_LOOKUP_IDX("F", 0, NULL, 1, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.5", 0, NULL, 1, GPIO_ACTIVE_HIGH),
{ },
},
};
@@ -244,9 +244,9 @@ static struct spi_board_info vision_spi_board_info[] __initdata = {
static struct gpiod_lookup_table vision_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
- GPIO_LOOKUP_IDX("A", 6, "cs", 0, GPIO_ACTIVE_LOW),
- GPIO_LOOKUP_IDX("A", 7, "cs", 1, GPIO_ACTIVE_LOW),
- GPIO_LOOKUP_IDX("G", 2, "cs", 2, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.0", 6, "cs", 0, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.0", 7, "cs", 1, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.6", 2, "cs", 2, GPIO_ACTIVE_LOW),
{ },
},
};
diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c
index 6cedf46efec6..ca508c7c4f2f 100644
--- a/drivers/gpio/gpio-ep93xx.c
+++ b/drivers/gpio/gpio-ep93xx.c
@@ -18,30 +18,10 @@
#include <linux/gpio/driver.h>
#include <linux/bitops.h>
#include <linux/seq_file.h>
-
-#define EP93XX_GPIO_F_INT_STATUS 0x5c
-#define EP93XX_GPIO_A_INT_STATUS 0xa0
-#define EP93XX_GPIO_B_INT_STATUS 0xbc
-
-/* Maximum value for gpio line identifiers */
-#define EP93XX_GPIO_LINE_MAX 63
-
-/* Number of GPIO chips in EP93XX */
-#define EP93XX_GPIO_CHIP_NUM 8
-
-/* Maximum value for irq capable line identifiers */
-#define EP93XX_GPIO_LINE_MAX_IRQ 23
-
-#define EP93XX_GPIO_A_IRQ_BASE 64
-#define EP93XX_GPIO_B_IRQ_BASE 72
-/*
- * Static mapping of GPIO bank F IRQS:
- * F0..F7 (16..24) to irq 80..87.
- */
-#define EP93XX_GPIO_F_IRQ_BASE 80
+#include <linux/interrupt.h>
struct ep93xx_gpio_irq_chip {
- u8 irq_offset;
+ void __iomem *base;
u8 int_unmasked;
u8 int_enabled;
u8 int_type1;
@@ -50,15 +30,11 @@ struct ep93xx_gpio_irq_chip {
};
struct ep93xx_gpio_chip {
+ void __iomem *base;
struct gpio_chip gc;
struct ep93xx_gpio_irq_chip *eic;
};
-struct ep93xx_gpio {
- void __iomem *base;
- struct ep93xx_gpio_chip gc[EP93XX_GPIO_CHIP_NUM];
-};
-
#define to_ep93xx_gpio_chip(x) container_of(x, struct ep93xx_gpio_chip, gc)
static struct ep93xx_gpio_irq_chip *to_ep93xx_gpio_irq_chip(struct gpio_chip *gc)
@@ -79,25 +55,23 @@ static struct ep93xx_gpio_irq_chip *to_ep93xx_gpio_irq_chip(struct gpio_chip *gc
#define EP93XX_INT_RAW_STATUS_OFFSET 0x14
#define EP93XX_INT_DEBOUNCE_OFFSET 0x18
-static void ep93xx_gpio_update_int_params(struct ep93xx_gpio *epg,
- struct ep93xx_gpio_irq_chip *eic)
+static void ep93xx_gpio_update_int_params(struct ep93xx_gpio_irq_chip *eic)
{
- writeb_relaxed(0, epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET);
+ writeb_relaxed(0, eic->base + EP93XX_INT_EN_OFFSET);
writeb_relaxed(eic->int_type2,
- epg->base + eic->irq_offset + EP93XX_INT_TYPE2_OFFSET);
+ eic->base + EP93XX_INT_TYPE2_OFFSET);
writeb_relaxed(eic->int_type1,
- epg->base + eic->irq_offset + EP93XX_INT_TYPE1_OFFSET);
+ eic->base + EP93XX_INT_TYPE1_OFFSET);
writeb_relaxed(eic->int_unmasked & eic->int_enabled,
- epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET);
+ eic->base + EP93XX_INT_EN_OFFSET);
}
static void ep93xx_gpio_int_debounce(struct gpio_chip *gc,
unsigned int offset, bool enable)
{
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
int port_mask = BIT(offset);
@@ -107,52 +81,43 @@ static void ep93xx_gpio_int_debounce(struct gpio_chip *gc,
eic->int_debounce &= ~port_mask;
writeb(eic->int_debounce,
- epg->base + eic->irq_offset + EP93XX_INT_DEBOUNCE_OFFSET);
+ eic->base + EP93XX_INT_DEBOUNCE_OFFSET);
}
-static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc)
+static u32 ep93xx_gpio_ab_irq_handler(struct gpio_chip *gc)
{
- struct gpio_chip *gc = irq_desc_get_handler_data(desc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- struct irq_chip *irqchip = irq_desc_get_chip(desc);
+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
unsigned long stat;
int offset;
- chained_irq_enter(irqchip, desc);
-
- /*
- * Dispatch the IRQs to the irqdomain of each A and B
- * gpiochip irqdomains depending on what has fired.
- * The tricky part is that the IRQ line is shared
- * between bank A and B and each has their own gpiochip.
- */
- stat = readb(epg->base + EP93XX_GPIO_A_INT_STATUS);
+ stat = readb(eic->base + EP93XX_INT_STATUS_OFFSET);
for_each_set_bit(offset, &stat, 8)
- generic_handle_domain_irq(epg->gc[0].gc.irq.domain,
- offset);
+ generic_handle_domain_irq(gc->irq.domain, offset);
- stat = readb(epg->base + EP93XX_GPIO_B_INT_STATUS);
- for_each_set_bit(offset, &stat, 8)
- generic_handle_domain_irq(epg->gc[1].gc.irq.domain,
- offset);
+ return stat;
+}
- chained_irq_exit(irqchip, desc);
+static irqreturn_t ep93xx_ab_irq_handler(int irq, void *dev_id)
+{
+ return IRQ_RETVAL(ep93xx_gpio_ab_irq_handler(dev_id));
}
static void ep93xx_gpio_f_irq_handler(struct irq_desc *desc)
{
- /*
- * map discontiguous hw irq range to continuous sw irq range:
- *
- * IRQ_EP93XX_GPIO{0..7}MUX -> EP93XX_GPIO_LINE_F{0..7}
- */
struct irq_chip *irqchip = irq_desc_get_chip(desc);
- unsigned int irq = irq_desc_get_irq(desc);
- int port_f_idx = (irq & 7) ^ 4; /* {20..23,48..51} -> {0..7} */
- int gpio_irq = EP93XX_GPIO_F_IRQ_BASE + port_f_idx;
+ struct gpio_chip *gc = irq_desc_get_handler_data(desc);
+ struct gpio_irq_chip *gic = &gc->irq;
+ unsigned int parent = irq_desc_get_irq(desc);
+ unsigned int i;
chained_irq_enter(irqchip, desc);
- generic_handle_irq(gpio_irq);
+ for (i = 0; i < gic->num_parents; i++)
+ if (gic->parents[i] == parent)
+ break;
+
+ if (i < gic->num_parents)
+ generic_handle_irq(irq_find_mapping(gc->irq.domain, i));
+
chained_irq_exit(irqchip, desc);
}
@@ -160,31 +125,29 @@ static void ep93xx_gpio_irq_ack(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- int port_mask = BIT(d->irq & 7);
+ int port_mask = BIT(irqd_to_hwirq(d));
if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) {
eic->int_type2 ^= port_mask; /* switch edge direction */
- ep93xx_gpio_update_int_params(epg, eic);
+ ep93xx_gpio_update_int_params(eic);
}
- writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
+ writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET);
}
static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- int port_mask = BIT(d->irq & 7);
+ int port_mask = BIT(irqd_to_hwirq(d));
if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH)
eic->int_type2 ^= port_mask; /* switch edge direction */
eic->int_unmasked &= ~port_mask;
- ep93xx_gpio_update_int_params(epg, eic);
+ ep93xx_gpio_update_int_params(eic);
- writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
+ writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET);
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
}
@@ -192,10 +155,9 @@ static void ep93xx_gpio_irq_mask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- eic->int_unmasked &= ~BIT(d->irq & 7);
- ep93xx_gpio_update_int_params(epg, eic);
+ eic->int_unmasked &= ~BIT(irqd_to_hwirq(d));
+ ep93xx_gpio_update_int_params(eic);
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
}
@@ -203,11 +165,10 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
- eic->int_unmasked |= BIT(d->irq & 7);
- ep93xx_gpio_update_int_params(epg, eic);
+ eic->int_unmasked |= BIT(irqd_to_hwirq(d));
+ ep93xx_gpio_update_int_params(eic);
}
/*
@@ -219,8 +180,7 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- int offset = d->irq & 7;
+ int offset = irqd_to_hwirq(d);
int port_mask = BIT(offset);
irq_flow_handler_t handler;
@@ -264,51 +224,11 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
eic->int_enabled |= port_mask;
- ep93xx_gpio_update_int_params(epg, eic);
+ ep93xx_gpio_update_int_params(eic);
return 0;
}
-/*************************************************************************
- * gpiolib interface for EP93xx on-chip GPIOs
- *************************************************************************/
-struct ep93xx_gpio_bank {
- const char *label;
- int data;
- int dir;
- int irq;
- int base;
- bool has_irq;
- bool has_hierarchical_irq;
- unsigned int irq_base;
-};
-
-#define EP93XX_GPIO_BANK(_label, _data, _dir, _irq, _base, _has_irq, _has_hier, _irq_base) \
- { \
- .label = _label, \
- .data = _data, \
- .dir = _dir, \
- .irq = _irq, \
- .base = _base, \
- .has_irq = _has_irq, \
- .has_hierarchical_irq = _has_hier, \
- .irq_base = _irq_base, \
- }
-
-static struct ep93xx_gpio_bank ep93xx_gpio_banks[] = {
- /* Bank A has 8 IRQs */
- EP93XX_GPIO_BANK("A", 0x00, 0x10, 0x90, 0, true, false, EP93XX_GPIO_A_IRQ_BASE),
- /* Bank B has 8 IRQs */
- EP93XX_GPIO_BANK("B", 0x04, 0x14, 0xac, 8, true, false, EP93XX_GPIO_B_IRQ_BASE),
- EP93XX_GPIO_BANK("C", 0x08, 0x18, 0x00, 40, false, false, 0),
- EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 0x00, 24, false, false, 0),
- EP93XX_GPIO_BANK("E", 0x20, 0x24, 0x00, 32, false, false, 0),
- /* Bank F has 8 IRQs */
- EP93XX_GPIO_BANK("F", 0x30, 0x34, 0x4c, 16, false, true, EP93XX_GPIO_F_IRQ_BASE),
- EP93XX_GPIO_BANK("G", 0x38, 0x3c, 0x00, 48, false, false, 0),
- EP93XX_GPIO_BANK("H", 0x40, 0x44, 0x00, 56, false, false, 0),
-};
-
static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset,
unsigned long config)
{
@@ -342,110 +262,105 @@ static const struct irq_chip gpio_eic_irq_chip = {
GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
-static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
- struct platform_device *pdev,
- struct ep93xx_gpio *epg,
- struct ep93xx_gpio_bank *bank)
+static int ep93xx_setup_irqs(struct platform_device *pdev,
+ struct ep93xx_gpio_chip *egc)
{
- void __iomem *data = epg->base + bank->data;
- void __iomem *dir = epg->base + bank->dir;
struct gpio_chip *gc = &egc->gc;
struct device *dev = &pdev->dev;
- struct gpio_irq_chip *girq;
- int err;
-
- err = bgpio_init(gc, dev, 1, data, NULL, NULL, dir, NULL, 0);
- if (err)
- return err;
-
- gc->label = bank->label;
- gc->base = bank->base;
-
- girq = &gc->irq;
- if (bank->has_irq || bank->has_hierarchical_irq) {
- gc->set_config = ep93xx_gpio_set_config;
- egc->eic = devm_kcalloc(dev, 1,
- sizeof(*egc->eic),
- GFP_KERNEL);
- if (!egc->eic)
- return -ENOMEM;
- egc->eic->irq_offset = bank->irq;
- gpio_irq_chip_set_chip(girq, &gpio_eic_irq_chip);
- }
+ struct gpio_irq_chip *girq = &gc->irq;
+ int ret, irq, i = 0;
+ void __iomem *intr = devm_platform_ioremap_resource_byname(pdev, "intr");
+
+ if (IS_ERR(intr))
+ return PTR_ERR(intr);
+
+ gc->set_config = ep93xx_gpio_set_config;
+ egc->eic = devm_kcalloc(dev, 1,
+ sizeof(*egc->eic),
+ GFP_KERNEL);
+ if (!egc->eic)
+ return -ENOMEM;
- if (bank->has_irq) {
- int ab_parent_irq = platform_get_irq(pdev, 0);
-
- girq->parent_handler = ep93xx_gpio_ab_irq_handler;
- girq->num_parents = 1;
- girq->parents = devm_kcalloc(dev, girq->num_parents,
- sizeof(*girq->parents),
- GFP_KERNEL);
- if (!girq->parents)
- return -ENOMEM;
- girq->default_type = IRQ_TYPE_NONE;
- girq->handler = handle_level_irq;
- girq->parents[0] = ab_parent_irq;
- girq->first = bank->irq_base;
- }
+ egc->eic->base = intr;
+ gpio_irq_chip_set_chip(girq, &gpio_eic_irq_chip);
+ girq->num_parents = platform_irq_count(pdev);
+ if (girq->num_parents == 0)
+ return -EINVAL;
+
+ girq->parents = devm_kcalloc(dev, girq->num_parents,
+ sizeof(*girq->parents),
+ GFP_KERNEL);
+ if (!girq->parents)
+ return -ENOMEM;
- /* Only bank F has especially funky IRQ handling */
- if (bank->has_hierarchical_irq) {
- int gpio_irq;
- int i;
+ if (girq->num_parents == 1) { /* A/B irqchips */
+ irq = platform_get_irq(pdev, 0);
+ ret = devm_request_irq(dev, irq,
+ ep93xx_ab_irq_handler,
+ IRQF_SHARED, gc->label, gc);
+ if (ret) {
+ dev_err(dev, "error requesting IRQ : %d\n", irq);
+ return ret;
+ }
- /*
- * FIXME: convert this to use hierarchical IRQ support!
- * this requires fixing the root irqchip to be hierarchical.
- */
+ girq->parents[0] = irq;
+ } else { /* F irqchip */
girq->parent_handler = ep93xx_gpio_f_irq_handler;
- girq->num_parents = 8;
- girq->parents = devm_kcalloc(dev, girq->num_parents,
- sizeof(*girq->parents),
- GFP_KERNEL);
- if (!girq->parents)
- return -ENOMEM;
- /* Pick resources 1..8 for these IRQs */
+
for (i = 0; i < girq->num_parents; i++) {
- girq->parents[i] = platform_get_irq(pdev, i + 1);
- gpio_irq = bank->irq_base + i;
- irq_set_chip_data(gpio_irq, &epg->gc[5]);
- irq_set_chip_and_handler(gpio_irq,
- girq->chip,
- handle_level_irq);
- irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST);
+ irq = platform_get_irq(pdev, i);
+ if (irq <= 0)
+ continue;
+
+ girq->parents[i] = irq;
}
- girq->default_type = IRQ_TYPE_NONE;
- girq->handler = handle_level_irq;
- girq->first = bank->irq_base;
+
+ girq->map = girq->parents;
}
- return devm_gpiochip_add_data(dev, gc, epg);
+ girq->default_type = IRQ_TYPE_NONE;
+ /* TODO: replace with handle_bad_irq once we are fully hierarchical */
+ girq->handler = handle_simple_irq;
+
+ return 0;
}
static int ep93xx_gpio_probe(struct platform_device *pdev)
{
- struct ep93xx_gpio *epg;
- int i;
-
- epg = devm_kzalloc(&pdev->dev, sizeof(*epg), GFP_KERNEL);
- if (!epg)
+ struct ep93xx_gpio_chip *egc;
+ struct gpio_chip *gc;
+ void __iomem *data;
+ void __iomem *dir;
+ int ret;
+
+ egc = devm_kzalloc(&pdev->dev, sizeof(*egc), GFP_KERNEL);
+ if (!egc)
return -ENOMEM;
- epg->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(epg->base))
- return PTR_ERR(epg->base);
+ data = devm_platform_ioremap_resource_byname(pdev, "data");
+ if (IS_ERR(data))
+ return PTR_ERR(data);
- for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) {
- struct ep93xx_gpio_chip *gc = &epg->gc[i];
- struct ep93xx_gpio_bank *bank = &ep93xx_gpio_banks[i];
+ dir = devm_platform_ioremap_resource_byname(pdev, "dir");
+ if (IS_ERR(dir))
+ return PTR_ERR(dir);
- if (ep93xx_gpio_add_bank(gc, pdev, epg, bank))
- dev_warn(&pdev->dev, "Unable to add gpio bank %s\n",
- bank->label);
+ gc = &egc->gc;
+ ret = bgpio_init(gc, &pdev->dev, 1, data, NULL, NULL, dir, NULL, 0);
+ if (ret) {
+ dev_err(&pdev->dev, "unable to init generic GPIO\n");
+ return ret;
}
- return 0;
+ gc->label = dev_name(&pdev->dev);
+ if (platform_irq_count(pdev) > 0) {
+ dev_dbg(&pdev->dev, "setting up irqs for %s\n", dev_name(&pdev->dev));
+ ret = ep93xx_setup_irqs(pdev, egc);
+ if (ret)
+ dev_err(&pdev->dev, "setup irqs failed for %s\n", dev_name(&pdev->dev));
+ }
+
+ return devm_gpiochip_add_data(&pdev->dev, gc, egc);
}
static struct platform_driver ep93xx_gpio_driver = {
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH 34/43] ARM: dts: add device tree for ep93xx Soc
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
2023-04-24 12:34 ` [PATCH 01/43] gpio: ep93xx: split device in multiple Nikita Shubin
@ 2023-04-24 12:34 ` Nikita Shubin
2023-04-24 11:28 ` Arnd Bergmann
2023-04-24 12:34 ` [PATCH 35/43] ARM: ep93xx: DT for the Cirrus ep93xx SoC platforms Nikita Shubin
` (5 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Nikita Shubin @ 2023-04-24 12:34 UTC (permalink / raw)
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Arnd Bergmann,
Olof Johansson, soc, Rob Herring, Krzysztof Kozlowski,
linux-arm-kernel, devicetree, linux-kernel
This adds a divice for Cirrus ep93xx SoC amd ts7250 board that has been
my testing target for ep93xx device support.
Also inluded device tree for Liebherr BK3.1 board through it's not a
complete support.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
arch/arm/boot/dts/Makefile | 1 +
arch/arm/boot/dts/ep93xx-bk3.dts | 96 ++++++
arch/arm/boot/dts/ep93xx-ts7250.dts | 113 ++++++++
arch/arm/boot/dts/ep93xx.dtsi | 433 ++++++++++++++++++++++++++++
4 files changed, 643 insertions(+)
create mode 100644 arch/arm/boot/dts/ep93xx-bk3.dts
create mode 100644 arch/arm/boot/dts/ep93xx-ts7250.dts
create mode 100644 arch/arm/boot/dts/ep93xx.dtsi
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index efe4152e5846..e6f48deeabed 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -1653,3 +1653,4 @@ dtb-$(CONFIG_ARCH_ASPEED) += \
aspeed-bmc-vegman-n110.dtb \
aspeed-bmc-vegman-rx20.dtb \
aspeed-bmc-vegman-sx20.dtb
+dtb-$(CONFIG_ARCH_EP93XX) += ep93xx-ts7250.dtb
diff --git a/arch/arm/boot/dts/ep93xx-bk3.dts b/arch/arm/boot/dts/ep93xx-bk3.dts
new file mode 100644
index 000000000000..c477af54ab56
--- /dev/null
+++ b/arch/arm/boot/dts/ep93xx-bk3.dts
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree file for Liebherr controller BK3.1 based on Cirrus EP9302 SoC
+ */
+/dts-v1/;
+#include "ep93xx.dtsi"
+
+/ {
+ model = "Liebherr controller BK3.1";
+ compatible = "liebherr,bk3", "cirrus,ep93xx";
+
+ memory {
+ device_type = "memory";
+ };
+
+ soc {
+ nand-parts@0 {
+ compatible = "technologic,ts7200-nand", "gen_nand";
+ reg = <0x60000000 0x8000000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "System";
+ reg = <0x00000000 0x01e00000>;
+ read-only;
+ };
+
+ partition@20000 {
+ label = "Data";
+ reg = <0x01e00000 0x05f20000>;
+ };
+
+ partition@7d20000 {
+ label = "RedBoot";
+ reg = <0x07d20000 0x002e0000>;
+ read-only;
+ };
+ };
+
+ syscon: syscon@80930000 {
+ pinctrl: pinctrl {
+ compatible = "cirrus,ep9301-pinctrl";
+ };
+ };
+
+ gpio1: gpio@80840004 {
+ /* PWM */
+ gpio-ranges = <&pinctrl 6 163 1>;
+ };
+ };
+};
+
+&gpio1 {
+ /* PWM */
+ gpio-ranges = <&pinctrl 6 163 1>;
+};
+
+&gpio4 {
+ gpio-ranges = <&pinctrl 0 97 2>;
+ status = "okay";
+};
+
+&gpio6 {
+ gpio-ranges = <&pinctrl 0 87 2>;
+ status = "okay";
+};
+
+&gpio7 {
+ gpio-ranges = <&pinctrl 2 199 4>;
+ status = "okay";
+};
+
+&i2c {
+ status = "okay";
+};
+
+&spi0: spi@808a0000 {
+ cs-gpios = <&gpio5 3 0>;
+ use_dma;
+ status = "okay";
+};
+
+ð0 {
+ copy_addr;
+ phy_id = < 1 >;
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&uart1 {
+ status = "okay";
+};
+
diff --git a/arch/arm/boot/dts/ep93xx-ts7250.dts b/arch/arm/boot/dts/ep93xx-ts7250.dts
new file mode 100644
index 000000000000..6562780333a3
--- /dev/null
+++ b/arch/arm/boot/dts/ep93xx-ts7250.dts
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree file for Technologic Systems ts7250 board based on Cirrus EP9302 SoC
+ */
+/dts-v1/;
+#include "ep93xx.dtsi"
+
+/ {
+ compatible = "technologic,ts7250", "cirrus,ep9301";
+ model = "TS-7250 SBC";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ memory@0 {
+ device_type = "memory";
+ /* should be set from ATAGS */
+ reg = <0x00000000 0x02000000>,
+ <0x000530c0 0x01fdd000>;
+ };
+
+ soc {
+ nand-parts@0 {
+ compatible = "technologic,ts7200-nand", "gen_nand";
+ reg = <0x60000000 0x8000000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "TS-BOOTROM";
+ reg = <0x00000000 0x00020000>;
+ read-only;
+ };
+
+ partition@20000 {
+ label = "Linux";
+ reg = <0x00020000 0x07d00000>;
+ };
+
+ partition@7d20000 {
+ label = "RedBoot";
+ reg = <0x07d20000 0x002e0000>;
+ read-only;
+ };
+ };
+
+ syscon: syscon@80930000 {
+ pinctrl: pinctrl {
+ compatible = "cirrus,ep9301-pinctrl";
+ };
+ };
+
+ rtc1: rtc@10800000 {
+ compatible = "dallas,rtc-m48t86";
+ reg = <0x10800000 0x1>,
+ <0x11700000 0x1>;
+ };
+
+ watchdog1: watchdog@23800000 {
+ compatible = "technologic,ts7200-wdt";
+ reg = <0x23800000 0x01>,
+ <0x23c00000 0x01>;
+ timeout-sec = <30>;
+ };
+ };
+};
+
+&gpio1 {
+ /* PWM */
+ gpio-ranges = <&pinctrl 6 163 1>;
+};
+
+&gpio4 {
+ gpio-ranges = <&pinctrl 0 97 2>;
+ status = "okay";
+};
+
+&gpio6 {
+ gpio-ranges = <&pinctrl 0 87 2>;
+ status = "okay";
+};
+
+&gpio7 {
+ gpio-ranges = <&pinctrl 2 199 4>;
+ status = "okay";
+};
+
+&i2c0 {
+ status = "okay";
+};
+
+&spi0 {
+ cs-gpios = <&gpio5 2 0>;
+ status = "okay";
+
+ tmp122_spi: tmp122@0 {
+ compatible = "ti,tmp122";
+ reg = <0>;
+ spi-max-frequency = <2000000>;
+ };
+};
+
+ð0 {
+ copy_addr;
+ phy_id = < 1 >;
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&uart1 {
+ status = "okay";
+};
diff --git a/arch/arm/boot/dts/ep93xx.dtsi b/arch/arm/boot/dts/ep93xx.dtsi
new file mode 100644
index 000000000000..67ecfde539af
--- /dev/null
+++ b/arch/arm/boot/dts/ep93xx.dtsi
@@ -0,0 +1,433 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree file for Cirrus Logic systems EP93XX SoC
+ */
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/clock/cirrus,ep93xx-clock.h>
+/ {
+ soc {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+ compatible = "simple-bus";
+
+ syscon: syscon@80930000 {
+ compatible = "cirrus,ep9301-syscon",
+ "syscon", "simple-mfd";
+ reg = <0x80930000 0x1000>;
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+
+ ep9301-reboot {
+ compatible = "cirrus,ep9301-reboot";
+ };
+
+ pinctrl: pinctrl {
+ regmap = <&syscon>;
+
+ spi_default_pins: pinctrl-spi {
+ function = "spi";
+ groups = "ssp";
+ };
+
+ ac97_default_pins: pinctrl-ac97 {
+ function = "ac97";
+ groups = "ac97";
+ };
+
+ i2s_on_ssp_pins: pinctrl-i2sonssp {
+ function = "i2s";
+ groups = "i2s_on_ssp";
+ };
+
+ i2s_on_ac97_pins: pinctrl-i2sonac97 {
+ function = "i2s";
+ groups = "i2s_on_ac97";
+ };
+
+ gpio1_default_pins: pinctrl-gpio1 {
+ function = "gpio1";
+ groups = "gpio1agrp";
+ };
+
+ pwm1_default_pins: pinctrl-pwm1 {
+ function = "pwm";
+ groups = "pwm1";
+ };
+
+ gpio2_default_pins: pinctrl-gpio2 {
+ function = "gpio2";
+ groups = "gpio2agrp";
+ };
+
+ gpio3_default_pins: pinctrl-gpio3 {
+ function = "gpio3";
+ groups = "gpio3agrp";
+ };
+
+ keypad_default_pins: pinctrl-keypad {
+ function = "keypad";
+ groups = "keypadgrp";
+ };
+
+ gpio4_default_pins: pinctrl-gpio4 {
+ function = "gpio4";
+ groups = "gpio4agrp";
+ };
+
+ gpio6_default_pins: pinctrl-gpio6 {
+ function = "gpio6";
+ groups = "gpio6agrp";
+ };
+
+ gpio7_default_pins: pinctrl-gpio7 {
+ function = "gpio7";
+ groups = "gpio7agrp";
+ };
+
+ ide_default_pins: pinctrl-ide {
+ function = "pata";
+ groups = "idegrp";
+ };
+
+ lcd_on_dram0_pins: pinctrl-rasteronsdram0 {
+ function = "lcd";
+ groups = "rasteronsdram0grp";
+ };
+
+ lcd_on_dram3_pins: pinctrl-rasteronsdram3 {
+ function = "lcd";
+ groups = "rasteronsdram3grp";
+ };
+ };
+ };
+
+ vic0: interrupt-controller@800b0000 {
+ compatible = "arm,pl192-vic";
+ interrupt-controller;
+ reg = <0x800b0000 0x1000>;
+ #interrupt-cells = <1>;
+ valid-mask = <0x7ffffffc>;
+ valid-wakeup-mask = <0x0>;
+ };
+
+ vic1: interrupt-controller@800c0000 {
+ compatible = "arm,pl192-vic";
+ interrupt-controller;
+ reg = <0x800c0000 0x1000>;
+ #interrupt-cells = <1>;
+ valid-mask = <0x1fffffff>;
+ valid-wakeup-mask = <0x0>;
+ };
+
+ timer: timer@80810000 {
+ compatible = "cirrus,ep9301-timer";
+ reg = <0x80810000 0x100>;
+ interrupt-parent = <&vic1>;
+ interrupts = <19>;
+ };
+
+ dma0: dma-controller@80000000 {
+ compatible = "cirrus,ep9301-dma-m2p";
+ reg = <0x80000000 0x0040>,
+ <0x80000040 0x0040>,
+ <0x80000080 0x0040>,
+ <0x800000c0 0x0040>,
+ <0x80000240 0x0040>,
+ <0x80000200 0x0040>,
+ <0x800002c0 0x0040>,
+ <0x80000280 0x0040>,
+ <0x80000340 0x0040>,
+ <0x80000300 0x0040>;
+ clocks = <&syscon EP93XX_CLK_M2P0>,
+ <&syscon EP93XX_CLK_M2P1>,
+ <&syscon EP93XX_CLK_M2P2>,
+ <&syscon EP93XX_CLK_M2P3>,
+ <&syscon EP93XX_CLK_M2P4>,
+ <&syscon EP93XX_CLK_M2P5>,
+ <&syscon EP93XX_CLK_M2P6>,
+ <&syscon EP93XX_CLK_M2P7>,
+ <&syscon EP93XX_CLK_M2P8>,
+ <&syscon EP93XX_CLK_M2P9>;
+ clock-names = "m2p0", "m2p1",
+ "m2p2", "m2p3",
+ "m2p4", "m2p5",
+ "m2p6", "m2p7",
+ "m2p8", "m2p9";
+ dma-channels = <10>;
+ interrupt-parent = <&vic0>;
+ interrupts = <7>, <8>, <9>, <10>, <11>,
+ <12>, <13>, <14>, <15>, <16>;
+ };
+
+ dma1: dma-controller@80000100 {
+ compatible = "cirrus,ep9301-dma-m2m";
+ reg = <0x80000100 0x0040>,
+ <0x80000140 0x0040>;
+ clocks = <&syscon EP93XX_CLK_M2M0>,
+ <&syscon EP93XX_CLK_M2M1>;
+ clock-names = "m2m0", "m2m1";
+ dma-channels = <2>;
+ interrupt-parent = <&vic0>;
+ interrupts = <17>, <18>;
+ };
+
+ gpio0: gpio@80840000 {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "A";
+ reg = <0x80840000 0x04>,
+ <0x80840010 0x04>,
+ <0x80840090 0x1c>;
+ reg-names = "data", "dir", "intr";
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ interrupt-parent = <&vic1>;
+ interrupts = <27>;
+ };
+
+ gpio1: gpio@80840004 {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "B";
+ reg = <0x80840004 0x04>,
+ <0x80840014 0x04>,
+ <0x808400ac 0x1c>;
+ reg-names = "data", "dir", "intr";
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ interrupt-parent = <&vic1>;
+ interrupts = <27>;
+ };
+
+ gpio2: gpio@80840008 {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "C";
+ reg = <0x80840008 0x04>,
+ <0x80840018 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio2_default_pins>;
+ };
+
+ gpio3: gpio@8084000c {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "D";
+ reg = <0x8084000c 0x04>,
+ <0x8084001c 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio3_default_pins>;
+ };
+
+ gpio4: gpio@80840020 {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "E";
+ reg = <0x80840020 0x04>,
+ <0x80840024 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio4_default_pins>;
+ };
+
+ gpio5: gpio@80840030 {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "F";
+ reg = <0x80840030 0x04>,
+ <0x80840034 0x04>,
+ <0x8084004c 0x1c>;
+ reg-names = "data", "dir", "intr";
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ interrupts-extended = <&vic0 19>, <&vic0 20>,
+ <&vic0 21>, <&vic0 22>,
+ <&vic1 15>, <&vic1 16>,
+ <&vic1 17>, <&vic1 18>;
+ };
+
+ gpio6: gpio@80840038 {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "G";
+ reg = <0x80840038 0x04>,
+ <0x8084003c 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio6_default_pins>;
+ };
+
+ gpio7: gpio@80840040 {
+ compatible = "cirrus,ep9301-gpio";
+ chip-label = "H";
+ reg = <0x80840040 0x04>,
+ <0x80840044 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio7_default_pins>;
+ };
+
+ ide: ide@800a0000 {
+ compatible = "cirrus,ep9312-pata";
+ reg = <0x800a0000 0x38>;
+ interrupt-parent = <&vic1>;
+ interrupts = <8>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&ide_default_pins>;
+ };
+
+ uart0: uart@808c0000 {
+ compatible = "arm,primecell";
+ reg = <0x808c0000 0x1000>;
+ arm,primecell-periphid = <0x00041010>;
+ clocks = <&syscon EP93XX_CLK_UART1>, <&syscon EP93XX_CLK_UART>;
+ clock-names = "apb:uart1", "apb_pclk";
+ interrupt-parent = <&vic1>;
+ interrupts = <20>;
+ status = "disabled";
+ };
+
+ uart1: uart@808d0000 {
+ compatible = "arm,primecell";
+ reg = <0x808d0000 0x1000>;
+ arm,primecell-periphid = <0x00041010>;
+ clocks = <&syscon EP93XX_CLK_UART2>, <&syscon EP93XX_CLK_UART>;
+ clock-names = "apb:uart2", "apb_pclk";
+ interrupt-parent = <&vic1>;
+ interrupts = <22>;
+ status = "disabled";
+ };
+
+ uart2: uart@808b0000 {
+ compatible = "arm,primecell";
+ reg = <0x808b0000 0x1000>;
+ arm,primecell-periphid = <0x00041010>;
+ clocks = <&syscon EP93XX_CLK_UART3>, <&syscon EP93XX_CLK_UART>;
+ clock-names = "apb:uart3", "apb_pclk";
+ interrupt-parent = <&vic1>;
+ interrupts = <23>;
+ status = "disabled";
+ };
+
+ eth0: eth@80010000 {
+ compatible = "cirrus,ep9301-eth";
+ reg = <0x80010000 0x10000>;
+ interrupt-parent = <&vic1>;
+ interrupts = <7>;
+ };
+
+ rtc0: rtc@80920000 {
+ compatible = "cirrus,ep9301-rtc";
+ reg = <0x80920000 0x100>;
+ };
+
+ spi0: spi@808a0000 {
+ compatible = "cirrus,ep9301-spi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x808a0000 0x18>;
+ interrupt-parent = <&vic1>;
+ interrupts = <21>;
+ clocks = <&syscon EP93XX_CLK_SPI>;
+ clock-names = "ep93xx-spi.0";
+ cs-gpios = <&gpio5 2 0>;
+ use_dma;
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi_default_pins>;
+ status = "disabled";
+ };
+
+ watchdog0: watchdog@80940000 {
+ compatible = "cirrus,ep9301-wdt";
+ reg = <0x80940000 0x08>;
+ };
+
+ pwm0: pwm@80910000 {
+ compatible = "cirrus,ep9301-pwm";
+ reg = <0x80910000 0x10>;
+ clocks = <&syscon EP93XX_CLK_PWM>;
+ clock-names = "pwm_clk";
+ status = "disabled";
+ };
+
+ pwm1: pwm@80910020 {
+ compatible = "cirrus,ep9301-pwm";
+ reg = <0x80910020 0x10>;
+ clocks = <&syscon EP93XX_CLK_PWM>;
+ clock-names = "pwm_clk";
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm1_default_pins>;
+ };
+
+ keypad: keypad@800f0000 {
+ compatible = "cirrus,ep9301-keypad";
+ reg = <0x800f0000 0x0c>;
+ interrupt-parent = <&vic0>;
+ interrupts = <29>;
+ clocks = <&syscon EP93XX_CLK_KEYPAD>;
+ clock-names = "ep93xx-keypad";
+ pinctrl-names = "default";
+ pinctrl-0 = <&keypad_default_pins>;
+ linux,keymap =
+ <KEY_UP>,
+ <KEY_DOWN>,
+ <KEY_VOLUMEDOWN>,
+ <KEY_HOME>,
+ <KEY_RIGHT>,
+ <KEY_LEFT>,
+ <KEY_ENTER>,
+ <KEY_VOLUMEUP>,
+ <KEY_F6>,
+ <KEY_F8>,
+ <KEY_F9>,
+ <KEY_F10>,
+ <KEY_F1>,
+ <KEY_F2>,
+ <KEY_F3>,
+ <KEY_POWER>;
+ };
+ };
+
+ i2c0: i2c0 {
+ compatible = "i2c-gpio";
+ sda-gpios = <&gpio6 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+ scl-gpios = <&gpio6 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ leds {
+ compatible = "gpio-leds";
+ led0 {
+ label = "grled";
+ gpios = <&gpio4 0 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "heartbeat";
+ function = LED_FUNCTION_HEARTBEAT;
+ };
+
+ led1 {
+ label = "rdled";
+ gpios = <&gpio4 1 GPIO_ACTIVE_HIGH>;
+ function = LED_FUNCTION_FAULT;
+ };
+ };
+};
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 34/43] ARM: dts: add device tree for ep93xx Soc
2023-04-24 12:34 ` [PATCH 34/43] ARM: dts: add device tree for ep93xx Soc Nikita Shubin
@ 2023-04-24 11:28 ` Arnd Bergmann
2023-04-28 15:13 ` Nikita Shubin
2023-04-28 21:56 ` Kris Bahnsen
0 siblings, 2 replies; 20+ messages in thread
From: Arnd Bergmann @ 2023-04-24 11:28 UTC (permalink / raw)
To: Nikita Shubin
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Olof Johansson,
soc, Rob Herring, Krzysztof Kozlowski, linux-arm-kernel,
devicetree, linux-kernel, Lukasz Majewski, support
On Mon, Apr 24, 2023, at 14:34, Nikita Shubin wrote:
> This adds a divice for Cirrus ep93xx SoC amd ts7250 board that has been
> my testing target for ep93xx device support.
>
> Also inluded device tree for Liebherr BK3.1 board through it's not a
> complete support.
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Can you describe which parts are missing for BK3.1 in the
changelog? I'm fairly sure that Liebherr is still supporting
this board, but I don't have a contact to add to Cc here.
I've added Lukasz Majewski to Cc here, as he originally worked
on BK3.1 and likely either has the hardware or knows someone
who does. Technologic Systems also lists the ts7250 as supported
on their website, but the only contact I found for them is the
generic support@embeddedTS.com. In case someone from Technologic
is available for giving the series a spin, see [1] for the
full set of patches.
Arnd
[1] https://lore.kernel.org/all/20230424123522.18302-1-nikita.shubin@maquefel.me/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 34/43] ARM: dts: add device tree for ep93xx Soc
2023-04-24 11:28 ` Arnd Bergmann
@ 2023-04-28 15:13 ` Nikita Shubin
2023-04-28 21:56 ` Kris Bahnsen
1 sibling, 0 replies; 20+ messages in thread
From: Nikita Shubin @ 2023-04-28 15:13 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Olof Johansson,
soc, Rob Herring, Krzysztof Kozlowski, linux-arm-kernel,
devicetree, linux-kernel, Lukasz Majewski, support
Hello Arnd!
On Mon, 2023-04-24 at 13:28 +0200, Arnd Bergmann wrote:
> On Mon, Apr 24, 2023, at 14:34, Nikita Shubin wrote:
> > This adds a divice for Cirrus ep93xx SoC amd ts7250 board that has
> > been
> > my testing target for ep93xx device support.
> >
> > Also inluded device tree for Liebherr BK3.1 board through it's not
> > a
> > complete support.
> >
> > Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
>
> Can you describe which parts are missing for BK3.1 in the
> changelog? I'm fairly sure that Liebherr is still supporting
> this board, but I don't have a contact to add to Cc here.
The current dt implementation is missing:
- I2S
- MMC on SPI
I will add those nodes so it will be a complete dt, however i have no
possibility to test it.
>
> I've added Lukasz Majewski to Cc here, as he originally worked
> on BK3.1 and likely either has the hardware or knows someone
> who does. Technologic Systems also lists the ts7250 as supported
> on their website, but the only contact I found for them is the
> generic support@embeddedTS.com. In case someone from Technologic
> is available for giving the series a spin, see [1] for the
> full set of patches.
>
> Arnd
>
> [1]
> https://lore.kernel.org/all/20230424123522.18302-1-nikita.shubin@maquefel.me/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 34/43] ARM: dts: add device tree for ep93xx Soc
2023-04-24 11:28 ` Arnd Bergmann
2023-04-28 15:13 ` Nikita Shubin
@ 2023-04-28 21:56 ` Kris Bahnsen
1 sibling, 0 replies; 20+ messages in thread
From: Kris Bahnsen @ 2023-04-28 21:56 UTC (permalink / raw)
To: Arnd Bergmann, Nikita Shubin
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Olof Johansson,
soc, Rob Herring, Krzysztof Kozlowski, linux-arm-kernel,
devicetree, linux-kernel, Lukasz Majewski, Michael Peters
On Mon, 2023-04-24 at 13:28 +0200, Arnd Bergmann wrote:
> On Mon, Apr 24, 2023, at 14:34, Nikita Shubin wrote:
> > This adds a divice for Cirrus ep93xx SoC amd ts7250 board that has been
> > my testing target for ep93xx device support.
> >
> > Also inluded device tree for Liebherr BK3.1 board through it's not a
> > complete support.
> >
> > Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
>
> Can you describe which parts are missing for BK3.1 in the
> changelog? I'm fairly sure that Liebherr is still supporting
> this board, but I don't have a contact to add to Cc here.
>
> I've added Lukasz Majewski to Cc here, as he originally worked
> on BK3.1 and likely either has the hardware or knows someone
> who does. Technologic Systems also lists the ts7250 as supported
> on their website, but the only contact I found for them is the
> generic support@embeddedTS.com. In case someone from Technologic
> is available for giving the series a spin, see [1] for the
> full set of patches.
>
> Arnd
>
> [1] https://lore.kernel.org/all/20230424123522.18302-1-nikita.shubin@maquefel.me/
Thanks Nikita for putting this together and getting us some
details/notes off-list to get us testing this quickly.
We ran a TS-7250 with this series applied through some of
our basic testing and everything is working as expected.
Tested-by: Michael Peters <mpeters@embeddedTS.com>
Reviewed-by: Kris Bahnsen <kris@embeddedTS.com>
-Kris
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 35/43] ARM: ep93xx: DT for the Cirrus ep93xx SoC platforms
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
2023-04-24 12:34 ` [PATCH 01/43] gpio: ep93xx: split device in multiple Nikita Shubin
2023-04-24 12:34 ` [PATCH 34/43] ARM: dts: add device tree for ep93xx Soc Nikita Shubin
@ 2023-04-24 12:34 ` Nikita Shubin
2023-06-01 5:33 ` [PATCH v1 01/43] gpio: ep93xx: split device in multiple Nikita Shubin
` (4 subsequent siblings)
7 siblings, 0 replies; 20+ messages in thread
From: Nikita Shubin @ 2023-04-24 12:34 UTC (permalink / raw)
Cc: Arnd Bergmann, Linus Walleij, Alexander Sverdlin, Russell King,
Hartley Sweeten, Arnd Bergmann, Russell King (Oracle),
Nick Desaulniers, Nathan Chancellor, Masahiro Yamada,
Nick Hawkins, Nicolas Saenz Julienne, linux-arm-kernel,
linux-kernel
This adds compulsory device tree support to the Cirrus ep93xx ARMv4
platform.
- We select PINCTRL_EP93xx
- We select COMMON_CLK_EP93XX, as clock driver moved out of platform
code
- We select ARCH_HAS_RESET_CONTROLLER
And also we need ARM_ATAG_DTB_COMPAT to update device tree with
information about memory passed from bootloader.
We have to leave all MACH options as they are used for board checking
before decomp, to turn off watchdog and ethernet DMA.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
Notes:
rfc->v0
- fixed typo
- removed board-dt.c completely
Alexander Sverdlin:
- platfrom -> platform
arch/arm/Makefile | 1 -
arch/arm/mach-ep93xx/Kconfig | 20 ++++++++++----------
arch/arm/mach-ep93xx/Makefile | 11 -----------
3 files changed, 10 insertions(+), 22 deletions(-)
delete mode 100644 arch/arm/mach-ep93xx/Makefile
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 485a439e22ca..8ad844ba777e 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -179,7 +179,6 @@ machine-$(CONFIG_ARCH_CLPS711X) += clps711x
machine-$(CONFIG_ARCH_DAVINCI) += davinci
machine-$(CONFIG_ARCH_DIGICOLOR) += digicolor
machine-$(CONFIG_ARCH_DOVE) += dove
-machine-$(CONFIG_ARCH_EP93XX) += ep93xx
machine-$(CONFIG_ARCH_EXYNOS) += exynos
machine-$(CONFIG_ARCH_FOOTBRIDGE) += footbridge
machine-$(CONFIG_ARCH_GEMINI) += gemini
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
index 703f3d232a60..812b71dcf60e 100644
--- a/arch/arm/mach-ep93xx/Kconfig
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -3,27 +3,27 @@ menuconfig ARCH_EP93XX
bool "EP93xx-based"
depends on ATAGS
depends on ARCH_MULTI_V4T
+ # CONFIG_ARCH_MULTI_V7 is not set
depends on CPU_LITTLE_ENDIAN
+ select ARCH_HAS_RESET_CONTROLLER
select ARCH_SPARSEMEM_ENABLE
select ARM_AMBA
select ARM_VIC
+ select ARM_APPENDED_DTB # Old Redboot bootloaders deployed
+ select ARM_ATAG_DTB_COMPAT # we need this to update dt memory node
+ select COMMON_CLK_EP93XX
+ select EP93XX_TIMER
select CLKSRC_MMIO
select CPU_ARM920T
select GPIOLIB
+ select PINCTRL
+ select PINCTRL_EP93XX
help
This enables support for the Cirrus EP93xx series of CPUs.
if ARCH_EP93XX
-menu "Cirrus EP93xx Implementation Options"
-
-config EP93XX_SOC_COMMON
- bool
- default y
- select SOC_BUS
- select LEDS_GPIO_REGISTER
-
-comment "EP93xx Platforms"
+# menu "EP93xx Platforms"
config MACH_BK3
bool "Support Liebherr BK3.1"
@@ -103,6 +103,6 @@ config MACH_VISION_EP9307
Say 'Y' here if you want your kernel to support the
Vision Engraving Systems EP9307 SoM.
-endmenu
+# endmenu
endif
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
deleted file mode 100644
index 62e37403df14..000000000000
--- a/arch/arm/mach-ep93xx/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for the linux kernel.
-#
-obj-y := core.o clock.o timer-ep93xx.o
-
-obj-$(CONFIG_EP93XX_DMA) += dma.o
-
-obj-$(CONFIG_MACH_EDB93XX) += edb93xx.o
-obj-$(CONFIG_MACH_TS72XX) += ts72xx.o
-obj-$(CONFIG_MACH_VISION_EP9307)+= vision_ep9307.o
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v1 01/43] gpio: ep93xx: split device in multiple
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
` (2 preceding siblings ...)
2023-04-24 12:34 ` [PATCH 35/43] ARM: ep93xx: DT for the Cirrus ep93xx SoC platforms Nikita Shubin
@ 2023-06-01 5:33 ` Nikita Shubin
2023-06-02 1:50 ` andy.shevchenko
2023-06-01 5:45 ` [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
` (3 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Nikita Shubin @ 2023-06-01 5:33 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, Lukasz Majewski, Bartosz Golaszewski
Cc: Nikita Shubin, Michael Peters, Kris Bahnsen, linux-arm-kernel,
linux-kernel, linux-gpio
This prepares ep93xx SOC gpio to convert into device tree driver:
- dropped banks and legacy defines
- split AB IRQ and make it shared
We are relying on IRQ number information A, B ports have single shared
IRQ, while F port have dedicated IRQ for each line.
Also we had to split single ep93xx platform_device into multiple, one
for each port, without this we can't do a full working transition from
legacy platform code into device tree capable. All GPIO_LOOKUP were
change to match new chip namings.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/mach-ep93xx/core.c | 121 +++++++++-
arch/arm/mach-ep93xx/edb93xx.c | 2 +-
arch/arm/mach-ep93xx/ts72xx.c | 4 +-
arch/arm/mach-ep93xx/vision_ep9307.c | 10 +-
drivers/gpio/gpio-ep93xx.c | 323 ++++++++++-----------------
5 files changed, 236 insertions(+), 224 deletions(-)
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 71b113976420..d61c1d2a0843 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -35,6 +35,7 @@
#include <linux/reboot.h>
#include <linux/usb/ohci_pdriver.h>
#include <linux/random.h>
+#include <linux/ioport.h>
#include "hardware.h"
#include <linux/platform_data/video-ep93xx.h>
@@ -139,9 +140,80 @@ EXPORT_SYMBOL_GPL(ep93xx_chip_revision);
/*************************************************************************
* EP93xx GPIO
*************************************************************************/
-static struct resource ep93xx_gpio_resource[] = {
- DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE, 0xcc),
+/* port A */
+static struct resource ep93xx_a_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x10, 0x04, "dir"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x90, 0x1c, "intr"),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB),
+};
+
+static struct platform_device ep93xx_a_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(ep93xx_a_gpio_resources),
+ .resource = ep93xx_a_gpio_resources,
+};
+
+/* port B */
+static struct resource ep93xx_b_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x04, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x14, 0x04, "dir"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0xac, 0x1c, "intr"),
+ DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB),
+};
+
+static struct platform_device ep93xx_b_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(ep93xx_b_gpio_resources),
+ .resource = ep93xx_b_gpio_resources,
+};
+
+/* port C */
+static struct resource ep93xx_c_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x08, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x18, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_c_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 2,
+ .num_resources = ARRAY_SIZE(ep93xx_c_gpio_resources),
+ .resource = ep93xx_c_gpio_resources,
+};
+
+/* port D */
+static struct resource ep93xx_d_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x0c, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x1c, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_d_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 3,
+ .num_resources = ARRAY_SIZE(ep93xx_d_gpio_resources),
+ .resource = ep93xx_d_gpio_resources,
+};
+
+/* port E */
+static struct resource ep93xx_e_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x20, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x24, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_e_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 4,
+ .num_resources = ARRAY_SIZE(ep93xx_e_gpio_resources),
+ .resource = ep93xx_e_gpio_resources,
+};
+
+/* port F */
+static struct resource ep93xx_f_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x30, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x34, 0x04, "dir"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x4c, 0x1c, "intr"),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO0MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO1MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO2MUX),
@@ -152,11 +224,34 @@ static struct resource ep93xx_gpio_resource[] = {
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO7MUX),
};
-static struct platform_device ep93xx_gpio_device = {
- .name = "gpio-ep93xx",
- .id = -1,
- .num_resources = ARRAY_SIZE(ep93xx_gpio_resource),
- .resource = ep93xx_gpio_resource,
+static struct platform_device ep93xx_f_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 5,
+ .num_resources = ARRAY_SIZE(ep93xx_f_gpio_resources),
+ .resource = ep93xx_f_gpio_resources,
+};
+
+/* port G */
+static struct resource ep93xx_g_gpio_resources[] = {
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x38, 0x04, "data"),
+ DEFINE_RES_MEM_NAMED(EP93XX_GPIO_PHYS_BASE + 0x3c, 0x04, "dir"),
+};
+
+static struct platform_device ep93xx_g_gpio = {
+ .name = "gpio-ep93xx",
+ .id = 6,
+ .num_resources = ARRAY_SIZE(ep93xx_g_gpio_resources),
+ .resource = ep93xx_g_gpio_resources,
+};
+
+static struct platform_device *ep93xx_gpio_device[] __initdata = {
+ &ep93xx_a_gpio,
+ &ep93xx_b_gpio,
+ &ep93xx_c_gpio,
+ &ep93xx_d_gpio,
+ &ep93xx_e_gpio,
+ &ep93xx_f_gpio,
+ &ep93xx_g_gpio,
};
/*************************************************************************
@@ -335,9 +430,9 @@ static struct gpiod_lookup_table ep93xx_i2c_gpiod_table = {
.dev_id = "i2c-gpio.0",
.table = {
/* Use local offsets on gpiochip/port "G" */
- GPIO_LOOKUP_IDX("G", 1, NULL, 0,
+ GPIO_LOOKUP_IDX("gpio-ep93xx.6", 1, NULL, 0,
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
- GPIO_LOOKUP_IDX("G", 0, NULL, 1,
+ GPIO_LOOKUP_IDX("gpio-ep93xx.6", 0, NULL, 1,
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
},
};
@@ -440,8 +535,8 @@ static struct gpiod_lookup_table ep93xx_leds_gpio_table = {
.dev_id = "leds-gpio",
.table = {
/* Use local offsets on gpiochip/port "E" */
- GPIO_LOOKUP_IDX("E", 0, NULL, 0, GPIO_ACTIVE_HIGH),
- GPIO_LOOKUP_IDX("E", 1, NULL, 1, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.4", 0, NULL, 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.4", 1, NULL, 1, GPIO_ACTIVE_HIGH),
{ }
},
};
@@ -974,6 +1069,7 @@ static struct device __init *ep93xx_init_soc(void)
struct device __init *ep93xx_init_devices(void)
{
struct device *parent;
+ int i;
/* Disallow access to MaverickCrunch initially */
ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA);
@@ -988,7 +1084,8 @@ struct device __init *ep93xx_init_devices(void)
parent = ep93xx_init_soc();
/* Get the GPIO working early, other devices need it */
- platform_device_register(&ep93xx_gpio_device);
+ for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_device); i++)
+ platform_device_register(ep93xx_gpio_device[i]);
amba_device_register(&uart1_device, &iomem_resource);
amba_device_register(&uart2_device, &iomem_resource);
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c
index 4b90899a66e9..c1e880946f72 100644
--- a/arch/arm/mach-ep93xx/edb93xx.c
+++ b/arch/arm/mach-ep93xx/edb93xx.c
@@ -105,7 +105,7 @@ static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
static struct gpiod_lookup_table edb93xx_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
- GPIO_LOOKUP("A", 6, "cs", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio-ep93xx.0", 6, "cs", GPIO_ACTIVE_LOW),
{ },
},
};
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index d3de7283ecb3..0bbdf587c685 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -268,7 +268,7 @@ static struct spi_board_info bk3_spi_board_info[] __initdata = {
static struct gpiod_lookup_table bk3_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
- GPIO_LOOKUP("F", 3, "cs", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio-ep93xx.5", 3, "cs", GPIO_ACTIVE_LOW),
{ },
},
};
@@ -318,7 +318,7 @@ static struct gpiod_lookup_table ts72xx_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
/* DIO_17 */
- GPIO_LOOKUP("F", 2, "cs", GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP("gpio-ep93xx.5", 2, "cs", GPIO_ACTIVE_LOW),
{ },
},
};
diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c
index 30d9cf3791eb..020223b0be2b 100644
--- a/arch/arm/mach-ep93xx/vision_ep9307.c
+++ b/arch/arm/mach-ep93xx/vision_ep9307.c
@@ -206,9 +206,9 @@ static struct gpiod_lookup_table vision_spi_mmc_gpio_table = {
.dev_id = "mmc_spi.2", /* "mmc_spi @ CS2 */
.table = {
/* Card detect */
- GPIO_LOOKUP_IDX("B", 7, NULL, 0, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.1", 7, NULL, 0, GPIO_ACTIVE_LOW),
/* Write protect */
- GPIO_LOOKUP_IDX("F", 0, NULL, 1, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.5", 0, NULL, 1, GPIO_ACTIVE_HIGH),
{ },
},
};
@@ -244,9 +244,9 @@ static struct spi_board_info vision_spi_board_info[] __initdata = {
static struct gpiod_lookup_table vision_spi_cs_gpio_table = {
.dev_id = "spi0",
.table = {
- GPIO_LOOKUP_IDX("A", 6, "cs", 0, GPIO_ACTIVE_LOW),
- GPIO_LOOKUP_IDX("A", 7, "cs", 1, GPIO_ACTIVE_LOW),
- GPIO_LOOKUP_IDX("G", 2, "cs", 2, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.0", 6, "cs", 0, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.0", 7, "cs", 1, GPIO_ACTIVE_LOW),
+ GPIO_LOOKUP_IDX("gpio-ep93xx.6", 2, "cs", 2, GPIO_ACTIVE_LOW),
{ },
},
};
diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c
index 6cedf46efec6..ca508c7c4f2f 100644
--- a/drivers/gpio/gpio-ep93xx.c
+++ b/drivers/gpio/gpio-ep93xx.c
@@ -18,30 +18,10 @@
#include <linux/gpio/driver.h>
#include <linux/bitops.h>
#include <linux/seq_file.h>
-
-#define EP93XX_GPIO_F_INT_STATUS 0x5c
-#define EP93XX_GPIO_A_INT_STATUS 0xa0
-#define EP93XX_GPIO_B_INT_STATUS 0xbc
-
-/* Maximum value for gpio line identifiers */
-#define EP93XX_GPIO_LINE_MAX 63
-
-/* Number of GPIO chips in EP93XX */
-#define EP93XX_GPIO_CHIP_NUM 8
-
-/* Maximum value for irq capable line identifiers */
-#define EP93XX_GPIO_LINE_MAX_IRQ 23
-
-#define EP93XX_GPIO_A_IRQ_BASE 64
-#define EP93XX_GPIO_B_IRQ_BASE 72
-/*
- * Static mapping of GPIO bank F IRQS:
- * F0..F7 (16..24) to irq 80..87.
- */
-#define EP93XX_GPIO_F_IRQ_BASE 80
+#include <linux/interrupt.h>
struct ep93xx_gpio_irq_chip {
- u8 irq_offset;
+ void __iomem *base;
u8 int_unmasked;
u8 int_enabled;
u8 int_type1;
@@ -50,15 +30,11 @@ struct ep93xx_gpio_irq_chip {
};
struct ep93xx_gpio_chip {
+ void __iomem *base;
struct gpio_chip gc;
struct ep93xx_gpio_irq_chip *eic;
};
-struct ep93xx_gpio {
- void __iomem *base;
- struct ep93xx_gpio_chip gc[EP93XX_GPIO_CHIP_NUM];
-};
-
#define to_ep93xx_gpio_chip(x) container_of(x, struct ep93xx_gpio_chip, gc)
static struct ep93xx_gpio_irq_chip *to_ep93xx_gpio_irq_chip(struct gpio_chip *gc)
@@ -79,25 +55,23 @@ static struct ep93xx_gpio_irq_chip *to_ep93xx_gpio_irq_chip(struct gpio_chip *gc
#define EP93XX_INT_RAW_STATUS_OFFSET 0x14
#define EP93XX_INT_DEBOUNCE_OFFSET 0x18
-static void ep93xx_gpio_update_int_params(struct ep93xx_gpio *epg,
- struct ep93xx_gpio_irq_chip *eic)
+static void ep93xx_gpio_update_int_params(struct ep93xx_gpio_irq_chip *eic)
{
- writeb_relaxed(0, epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET);
+ writeb_relaxed(0, eic->base + EP93XX_INT_EN_OFFSET);
writeb_relaxed(eic->int_type2,
- epg->base + eic->irq_offset + EP93XX_INT_TYPE2_OFFSET);
+ eic->base + EP93XX_INT_TYPE2_OFFSET);
writeb_relaxed(eic->int_type1,
- epg->base + eic->irq_offset + EP93XX_INT_TYPE1_OFFSET);
+ eic->base + EP93XX_INT_TYPE1_OFFSET);
writeb_relaxed(eic->int_unmasked & eic->int_enabled,
- epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET);
+ eic->base + EP93XX_INT_EN_OFFSET);
}
static void ep93xx_gpio_int_debounce(struct gpio_chip *gc,
unsigned int offset, bool enable)
{
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
int port_mask = BIT(offset);
@@ -107,52 +81,43 @@ static void ep93xx_gpio_int_debounce(struct gpio_chip *gc,
eic->int_debounce &= ~port_mask;
writeb(eic->int_debounce,
- epg->base + eic->irq_offset + EP93XX_INT_DEBOUNCE_OFFSET);
+ eic->base + EP93XX_INT_DEBOUNCE_OFFSET);
}
-static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc)
+static u32 ep93xx_gpio_ab_irq_handler(struct gpio_chip *gc)
{
- struct gpio_chip *gc = irq_desc_get_handler_data(desc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- struct irq_chip *irqchip = irq_desc_get_chip(desc);
+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
unsigned long stat;
int offset;
- chained_irq_enter(irqchip, desc);
-
- /*
- * Dispatch the IRQs to the irqdomain of each A and B
- * gpiochip irqdomains depending on what has fired.
- * The tricky part is that the IRQ line is shared
- * between bank A and B and each has their own gpiochip.
- */
- stat = readb(epg->base + EP93XX_GPIO_A_INT_STATUS);
+ stat = readb(eic->base + EP93XX_INT_STATUS_OFFSET);
for_each_set_bit(offset, &stat, 8)
- generic_handle_domain_irq(epg->gc[0].gc.irq.domain,
- offset);
+ generic_handle_domain_irq(gc->irq.domain, offset);
- stat = readb(epg->base + EP93XX_GPIO_B_INT_STATUS);
- for_each_set_bit(offset, &stat, 8)
- generic_handle_domain_irq(epg->gc[1].gc.irq.domain,
- offset);
+ return stat;
+}
- chained_irq_exit(irqchip, desc);
+static irqreturn_t ep93xx_ab_irq_handler(int irq, void *dev_id)
+{
+ return IRQ_RETVAL(ep93xx_gpio_ab_irq_handler(dev_id));
}
static void ep93xx_gpio_f_irq_handler(struct irq_desc *desc)
{
- /*
- * map discontiguous hw irq range to continuous sw irq range:
- *
- * IRQ_EP93XX_GPIO{0..7}MUX -> EP93XX_GPIO_LINE_F{0..7}
- */
struct irq_chip *irqchip = irq_desc_get_chip(desc);
- unsigned int irq = irq_desc_get_irq(desc);
- int port_f_idx = (irq & 7) ^ 4; /* {20..23,48..51} -> {0..7} */
- int gpio_irq = EP93XX_GPIO_F_IRQ_BASE + port_f_idx;
+ struct gpio_chip *gc = irq_desc_get_handler_data(desc);
+ struct gpio_irq_chip *gic = &gc->irq;
+ unsigned int parent = irq_desc_get_irq(desc);
+ unsigned int i;
chained_irq_enter(irqchip, desc);
- generic_handle_irq(gpio_irq);
+ for (i = 0; i < gic->num_parents; i++)
+ if (gic->parents[i] == parent)
+ break;
+
+ if (i < gic->num_parents)
+ generic_handle_irq(irq_find_mapping(gc->irq.domain, i));
+
chained_irq_exit(irqchip, desc);
}
@@ -160,31 +125,29 @@ static void ep93xx_gpio_irq_ack(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- int port_mask = BIT(d->irq & 7);
+ int port_mask = BIT(irqd_to_hwirq(d));
if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) {
eic->int_type2 ^= port_mask; /* switch edge direction */
- ep93xx_gpio_update_int_params(epg, eic);
+ ep93xx_gpio_update_int_params(eic);
}
- writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
+ writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET);
}
static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- int port_mask = BIT(d->irq & 7);
+ int port_mask = BIT(irqd_to_hwirq(d));
if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH)
eic->int_type2 ^= port_mask; /* switch edge direction */
eic->int_unmasked &= ~port_mask;
- ep93xx_gpio_update_int_params(epg, eic);
+ ep93xx_gpio_update_int_params(eic);
- writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
+ writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET);
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
}
@@ -192,10 +155,9 @@ static void ep93xx_gpio_irq_mask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- eic->int_unmasked &= ~BIT(d->irq & 7);
- ep93xx_gpio_update_int_params(epg, eic);
+ eic->int_unmasked &= ~BIT(irqd_to_hwirq(d));
+ ep93xx_gpio_update_int_params(eic);
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
}
@@ -203,11 +165,10 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
- eic->int_unmasked |= BIT(d->irq & 7);
- ep93xx_gpio_update_int_params(epg, eic);
+ eic->int_unmasked |= BIT(irqd_to_hwirq(d));
+ ep93xx_gpio_update_int_params(eic);
}
/*
@@ -219,8 +180,7 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
- struct ep93xx_gpio *epg = gpiochip_get_data(gc);
- int offset = d->irq & 7;
+ int offset = irqd_to_hwirq(d);
int port_mask = BIT(offset);
irq_flow_handler_t handler;
@@ -264,51 +224,11 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
eic->int_enabled |= port_mask;
- ep93xx_gpio_update_int_params(epg, eic);
+ ep93xx_gpio_update_int_params(eic);
return 0;
}
-/*************************************************************************
- * gpiolib interface for EP93xx on-chip GPIOs
- *************************************************************************/
-struct ep93xx_gpio_bank {
- const char *label;
- int data;
- int dir;
- int irq;
- int base;
- bool has_irq;
- bool has_hierarchical_irq;
- unsigned int irq_base;
-};
-
-#define EP93XX_GPIO_BANK(_label, _data, _dir, _irq, _base, _has_irq, _has_hier, _irq_base) \
- { \
- .label = _label, \
- .data = _data, \
- .dir = _dir, \
- .irq = _irq, \
- .base = _base, \
- .has_irq = _has_irq, \
- .has_hierarchical_irq = _has_hier, \
- .irq_base = _irq_base, \
- }
-
-static struct ep93xx_gpio_bank ep93xx_gpio_banks[] = {
- /* Bank A has 8 IRQs */
- EP93XX_GPIO_BANK("A", 0x00, 0x10, 0x90, 0, true, false, EP93XX_GPIO_A_IRQ_BASE),
- /* Bank B has 8 IRQs */
- EP93XX_GPIO_BANK("B", 0x04, 0x14, 0xac, 8, true, false, EP93XX_GPIO_B_IRQ_BASE),
- EP93XX_GPIO_BANK("C", 0x08, 0x18, 0x00, 40, false, false, 0),
- EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 0x00, 24, false, false, 0),
- EP93XX_GPIO_BANK("E", 0x20, 0x24, 0x00, 32, false, false, 0),
- /* Bank F has 8 IRQs */
- EP93XX_GPIO_BANK("F", 0x30, 0x34, 0x4c, 16, false, true, EP93XX_GPIO_F_IRQ_BASE),
- EP93XX_GPIO_BANK("G", 0x38, 0x3c, 0x00, 48, false, false, 0),
- EP93XX_GPIO_BANK("H", 0x40, 0x44, 0x00, 56, false, false, 0),
-};
-
static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset,
unsigned long config)
{
@@ -342,110 +262,105 @@ static const struct irq_chip gpio_eic_irq_chip = {
GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
-static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
- struct platform_device *pdev,
- struct ep93xx_gpio *epg,
- struct ep93xx_gpio_bank *bank)
+static int ep93xx_setup_irqs(struct platform_device *pdev,
+ struct ep93xx_gpio_chip *egc)
{
- void __iomem *data = epg->base + bank->data;
- void __iomem *dir = epg->base + bank->dir;
struct gpio_chip *gc = &egc->gc;
struct device *dev = &pdev->dev;
- struct gpio_irq_chip *girq;
- int err;
-
- err = bgpio_init(gc, dev, 1, data, NULL, NULL, dir, NULL, 0);
- if (err)
- return err;
-
- gc->label = bank->label;
- gc->base = bank->base;
-
- girq = &gc->irq;
- if (bank->has_irq || bank->has_hierarchical_irq) {
- gc->set_config = ep93xx_gpio_set_config;
- egc->eic = devm_kcalloc(dev, 1,
- sizeof(*egc->eic),
- GFP_KERNEL);
- if (!egc->eic)
- return -ENOMEM;
- egc->eic->irq_offset = bank->irq;
- gpio_irq_chip_set_chip(girq, &gpio_eic_irq_chip);
- }
+ struct gpio_irq_chip *girq = &gc->irq;
+ int ret, irq, i = 0;
+ void __iomem *intr = devm_platform_ioremap_resource_byname(pdev, "intr");
+
+ if (IS_ERR(intr))
+ return PTR_ERR(intr);
+
+ gc->set_config = ep93xx_gpio_set_config;
+ egc->eic = devm_kcalloc(dev, 1,
+ sizeof(*egc->eic),
+ GFP_KERNEL);
+ if (!egc->eic)
+ return -ENOMEM;
- if (bank->has_irq) {
- int ab_parent_irq = platform_get_irq(pdev, 0);
-
- girq->parent_handler = ep93xx_gpio_ab_irq_handler;
- girq->num_parents = 1;
- girq->parents = devm_kcalloc(dev, girq->num_parents,
- sizeof(*girq->parents),
- GFP_KERNEL);
- if (!girq->parents)
- return -ENOMEM;
- girq->default_type = IRQ_TYPE_NONE;
- girq->handler = handle_level_irq;
- girq->parents[0] = ab_parent_irq;
- girq->first = bank->irq_base;
- }
+ egc->eic->base = intr;
+ gpio_irq_chip_set_chip(girq, &gpio_eic_irq_chip);
+ girq->num_parents = platform_irq_count(pdev);
+ if (girq->num_parents == 0)
+ return -EINVAL;
+
+ girq->parents = devm_kcalloc(dev, girq->num_parents,
+ sizeof(*girq->parents),
+ GFP_KERNEL);
+ if (!girq->parents)
+ return -ENOMEM;
- /* Only bank F has especially funky IRQ handling */
- if (bank->has_hierarchical_irq) {
- int gpio_irq;
- int i;
+ if (girq->num_parents == 1) { /* A/B irqchips */
+ irq = platform_get_irq(pdev, 0);
+ ret = devm_request_irq(dev, irq,
+ ep93xx_ab_irq_handler,
+ IRQF_SHARED, gc->label, gc);
+ if (ret) {
+ dev_err(dev, "error requesting IRQ : %d\n", irq);
+ return ret;
+ }
- /*
- * FIXME: convert this to use hierarchical IRQ support!
- * this requires fixing the root irqchip to be hierarchical.
- */
+ girq->parents[0] = irq;
+ } else { /* F irqchip */
girq->parent_handler = ep93xx_gpio_f_irq_handler;
- girq->num_parents = 8;
- girq->parents = devm_kcalloc(dev, girq->num_parents,
- sizeof(*girq->parents),
- GFP_KERNEL);
- if (!girq->parents)
- return -ENOMEM;
- /* Pick resources 1..8 for these IRQs */
+
for (i = 0; i < girq->num_parents; i++) {
- girq->parents[i] = platform_get_irq(pdev, i + 1);
- gpio_irq = bank->irq_base + i;
- irq_set_chip_data(gpio_irq, &epg->gc[5]);
- irq_set_chip_and_handler(gpio_irq,
- girq->chip,
- handle_level_irq);
- irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST);
+ irq = platform_get_irq(pdev, i);
+ if (irq <= 0)
+ continue;
+
+ girq->parents[i] = irq;
}
- girq->default_type = IRQ_TYPE_NONE;
- girq->handler = handle_level_irq;
- girq->first = bank->irq_base;
+
+ girq->map = girq->parents;
}
- return devm_gpiochip_add_data(dev, gc, epg);
+ girq->default_type = IRQ_TYPE_NONE;
+ /* TODO: replace with handle_bad_irq once we are fully hierarchical */
+ girq->handler = handle_simple_irq;
+
+ return 0;
}
static int ep93xx_gpio_probe(struct platform_device *pdev)
{
- struct ep93xx_gpio *epg;
- int i;
-
- epg = devm_kzalloc(&pdev->dev, sizeof(*epg), GFP_KERNEL);
- if (!epg)
+ struct ep93xx_gpio_chip *egc;
+ struct gpio_chip *gc;
+ void __iomem *data;
+ void __iomem *dir;
+ int ret;
+
+ egc = devm_kzalloc(&pdev->dev, sizeof(*egc), GFP_KERNEL);
+ if (!egc)
return -ENOMEM;
- epg->base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(epg->base))
- return PTR_ERR(epg->base);
+ data = devm_platform_ioremap_resource_byname(pdev, "data");
+ if (IS_ERR(data))
+ return PTR_ERR(data);
- for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) {
- struct ep93xx_gpio_chip *gc = &epg->gc[i];
- struct ep93xx_gpio_bank *bank = &ep93xx_gpio_banks[i];
+ dir = devm_platform_ioremap_resource_byname(pdev, "dir");
+ if (IS_ERR(dir))
+ return PTR_ERR(dir);
- if (ep93xx_gpio_add_bank(gc, pdev, epg, bank))
- dev_warn(&pdev->dev, "Unable to add gpio bank %s\n",
- bank->label);
+ gc = &egc->gc;
+ ret = bgpio_init(gc, &pdev->dev, 1, data, NULL, NULL, dir, NULL, 0);
+ if (ret) {
+ dev_err(&pdev->dev, "unable to init generic GPIO\n");
+ return ret;
}
- return 0;
+ gc->label = dev_name(&pdev->dev);
+ if (platform_irq_count(pdev) > 0) {
+ dev_dbg(&pdev->dev, "setting up irqs for %s\n", dev_name(&pdev->dev));
+ ret = ep93xx_setup_irqs(pdev, egc);
+ if (ret)
+ dev_err(&pdev->dev, "setup irqs failed for %s\n", dev_name(&pdev->dev));
+ }
+
+ return devm_gpiochip_add_data(&pdev->dev, gc, egc);
}
static struct platform_driver ep93xx_gpio_driver = {
--
2.37.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v1 01/43] gpio: ep93xx: split device in multiple
2023-06-01 5:33 ` [PATCH v1 01/43] gpio: ep93xx: split device in multiple Nikita Shubin
@ 2023-06-02 1:50 ` andy.shevchenko
2023-06-15 16:56 ` Nikita Shubin
0 siblings, 1 reply; 20+ messages in thread
From: andy.shevchenko @ 2023-06-02 1:50 UTC (permalink / raw)
To: Nikita Shubin
Cc: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, Lukasz Majewski, Bartosz Golaszewski,
Michael Peters, Kris Bahnsen, linux-arm-kernel, linux-kernel,
linux-gpio
Thu, Jun 01, 2023 at 08:33:52AM +0300, Nikita Shubin kirjoitti:
> This prepares ep93xx SOC gpio to convert into device tree driver:
> - dropped banks and legacy defines
> - split AB IRQ and make it shared
>
> We are relying on IRQ number information A, B ports have single shared
> IRQ, while F port have dedicated IRQ for each line.
>
> Also we had to split single ep93xx platform_device into multiple, one
> for each port, without this we can't do a full working transition from
> legacy platform code into device tree capable. All GPIO_LOOKUP were
> change to match new chip namings.
First of all, check if you added In-Reply-to email header to the previous
thread, at least `b4` downloaded 188 messages in this one so far. Second,
the previous was kinda v0, while we usually assume that non-versioned series
is v1. This is a bit ambiguous.
...
> + GPIO_LOOKUP_IDX("gpio-ep93xx.4", 1, NULL, 1, GPIO_ACTIVE_HIGH),
TAB used instead of space.
...
> struct device __init *ep93xx_init_devices(void)
> {
> struct device *parent;
> + int i;
It's unsigned, right?
> + for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_device); i++)
> + platform_device_register(ep93xx_gpio_device[i]);
...
> writeb(eic->int_debounce,
> - epg->base + eic->irq_offset + EP93XX_INT_DEBOUNCE_OFFSET);
> + eic->base + EP93XX_INT_DEBOUNCE_OFFSET);
Now this can be a single line. Also some other cases may be optimized.
...
> + void __iomem *intr = devm_platform_ioremap_resource_byname(pdev, "intr");
It's less error prone if the assignment is split from definition and moved
closer to its (first) user...
> +
...here.
> + if (IS_ERR(intr))
> + return PTR_ERR(intr);
...
> + egc->eic = devm_kcalloc(dev, 1,
> + sizeof(*egc->eic),
> + GFP_KERNEL);
Why kcalloc(1), is this a part that will be (slightly) modified in the next
patches in the series?
> + if (!egc->eic)
> + return -ENOMEM;
>
...
> + irq = platform_get_irq(pdev, 0);
No return value check?
> + ret = devm_request_irq(dev, irq,
> + ep93xx_ab_irq_handler,
> + IRQF_SHARED, gc->label, gc);
> + if (ret) {
> + dev_err(dev, "error requesting IRQ : %d\n", irq);
> + return ret;
If it's soslely part of the ->probe() flow, you may use dev_err_probe().
> + }
>
> + girq->parents[0] = irq;
...
> for (i = 0; i < girq->num_parents; i++) {
> + irq = platform_get_irq(pdev, i);
> + if (irq <= 0)
== 0 is never happen case. Why?
> + continue;
> +
> + girq->parents[i] = irq;
> }
> + ret = bgpio_init(gc, &pdev->dev, 1, data, NULL, NULL, dir, NULL, 0);
> + if (ret) {
> + dev_err(&pdev->dev, "unable to init generic GPIO\n");
> + return ret;
return dev_err_probe(...);
> }
...
> + if (platform_irq_count(pdev) > 0) {
Do you need this check?
> + dev_dbg(&pdev->dev, "setting up irqs for %s\n", dev_name(&pdev->dev));
> + ret = ep93xx_setup_irqs(pdev, egc);
> + if (ret)
> + dev_err(&pdev->dev, "setup irqs failed for %s\n", dev_name(&pdev->dev));
If it's an error, why continuing?
> + }
--
With Best Regards,
Andy Shevchenko
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH v1 01/43] gpio: ep93xx: split device in multiple
2023-06-02 1:50 ` andy.shevchenko
@ 2023-06-15 16:56 ` Nikita Shubin
0 siblings, 0 replies; 20+ messages in thread
From: Nikita Shubin @ 2023-06-15 16:56 UTC (permalink / raw)
To: andy.shevchenko
Cc: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, Lukasz Majewski, Bartosz Golaszewski,
Michael Peters, Kris Bahnsen, linux-arm-kernel, linux-kernel,
linux-gpio
Hello Andy !
On Fri, 2023-06-02 at 04:50 +0300, andy.shevchenko@gmail.com wrote:
> Thu, Jun 01, 2023 at 08:33:52AM +0300, Nikita Shubin kirjoitti:
> > This prepares ep93xx SOC gpio to convert into device tree driver:
> > - dropped banks and legacy defines
> > - split AB IRQ and make it shared
> >
> > We are relying on IRQ number information A, B ports have single
> > shared
> > IRQ, while F port have dedicated IRQ for each line.
> >
> > Also we had to split single ep93xx platform_device into multiple,
> > one
> > for each port, without this we can't do a full working transition
> > from
> > legacy platform code into device tree capable. All GPIO_LOOKUP were
> > change to match new chip namings.
>
> First of all, check if you added In-Reply-to email header to the
> previous
> thread, at least `b4` downloaded 188 messages in this one so far.
> Second,
> the previous was kinda v0, while we usually assume that non-versioned
> series
> is v1. This is a bit ambiguous.
>
> ...
>
> > + GPIO_LOOKUP_IDX("gpio-ep93xx.4", 1, NULL, 1,
> > GPIO_ACTIVE_HIGH),
>
> TAB used instead of space.
>
> ...
>
> > struct device __init *ep93xx_init_devices(void)
> > {
> > struct device *parent;
> > + int i;
>
> It's unsigned, right?
>
> > + for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_device); i++)
> > + platform_device_register(ep93xx_gpio_device[i]);
>
> ...
>
> > writeb(eic->int_debounce,
> > - epg->base + eic->irq_offset +
> > EP93XX_INT_DEBOUNCE_OFFSET);
> > + eic->base + EP93XX_INT_DEBOUNCE_OFFSET);
>
> Now this can be a single line. Also some other cases may be
> optimized.
>
> ...
>
> > + void __iomem *intr =
> > devm_platform_ioremap_resource_byname(pdev, "intr");
>
> It's less error prone if the assignment is split from definition and
> moved
> closer to its (first) user...
>
> > +
>
> ...here.
>
> > + if (IS_ERR(intr))
> > + return PTR_ERR(intr);
>
> ...
>
> > + egc->eic = devm_kcalloc(dev, 1,
> > + sizeof(*egc->eic),
> > + GFP_KERNEL);
>
> Why kcalloc(1), is this a part that will be (slightly) modified in
> the next
> patches in the series?
>
> > + if (!egc->eic)
> > + return -ENOMEM;
> >
> ...
>
> > + irq = platform_get_irq(pdev, 0);
>
> No return value check?
>
> > + ret = devm_request_irq(dev, irq,
> > + ep93xx_ab_irq_handler,
> > + IRQF_SHARED, gc->label, gc);
> > + if (ret) {
> > + dev_err(dev, "error requesting IRQ : %d\n",
> > irq);
> > + return ret;
>
> If it's soslely part of the ->probe() flow, you may use
> dev_err_probe().
>
> > + }
> >
> > + girq->parents[0] = irq;
>
> ...
>
> > for (i = 0; i < girq->num_parents; i++) {
> > + irq = platform_get_irq(pdev, i);
> > + if (irq <= 0)
>
> == 0 is never happen case. Why?
>
> > + continue;
> > +
> > + girq->parents[i] = irq;
> > }
>
> > + ret = bgpio_init(gc, &pdev->dev, 1, data, NULL, NULL, dir,
> > NULL, 0);
> > + if (ret) {
> > + dev_err(&pdev->dev, "unable to init generic
> > GPIO\n");
> > + return ret;
>
> return dev_err_probe(...);
>
> > }
>
> ...
>
> > + if (platform_irq_count(pdev) > 0) {
>
> Do you need this check?
Only A/B/F ports have irq's so we don't bother setting up for other
ports.
>
> > + dev_dbg(&pdev->dev, "setting up irqs for %s\n",
> > dev_name(&pdev->dev));
> > + ret = ep93xx_setup_irqs(pdev, egc);
> > + if (ret)
> > + dev_err(&pdev->dev, "setup irqs failed for
> > %s\n", dev_name(&pdev->dev));
>
> If it's an error, why continuing?
Well - it's not fatal, we can still use gpios even without irq's but we
should warn.
All other comments acknowledged and fixed, thank you.
>
> > + }
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
` (3 preceding siblings ...)
2023-06-01 5:33 ` [PATCH v1 01/43] gpio: ep93xx: split device in multiple Nikita Shubin
@ 2023-06-01 5:45 ` Nikita Shubin
2023-06-02 7:27 ` Linus Walleij
` (3 more replies)
2023-06-01 5:45 ` [PATCH v1 22/43] dma: " Nikita Shubin
` (2 subsequent siblings)
7 siblings, 4 replies; 20+ messages in thread
From: Nikita Shubin @ 2023-06-01 5:45 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Nikita Shubin, Michael Peters, Kris Bahnsen, linux-arm-kernel,
linux-kernel, netdev
- find register range from the device tree
- get "copy_addr" from the device tree
- get phy_id from the device tree
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
Notes:
v0 -> v1:
- dropped platform data entirely
- dropped copy_addr
- use phy-handle instead of using non-conventional phy-id
arch/arm/mach-ep93xx/platform.h | 2 +-
drivers/net/ethernet/cirrus/ep93xx_eth.c | 67 +++++++++++++-----------
2 files changed, 37 insertions(+), 32 deletions(-)
diff --git a/arch/arm/mach-ep93xx/platform.h b/arch/arm/mach-ep93xx/platform.h
index 5fb1b919133f..3cf2113491d8 100644
--- a/arch/arm/mach-ep93xx/platform.h
+++ b/arch/arm/mach-ep93xx/platform.h
@@ -5,8 +5,8 @@
#ifndef __ASSEMBLY__
-#include <linux/platform_data/eth-ep93xx.h>
#include <linux/reboot.h>
+#include <linux/platform_data/eth-ep93xx.h>
struct device;
struct i2c_board_info;
diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
index 8627ab19d470..41096d4830ff 100644
--- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
+++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
@@ -17,12 +17,11 @@
#include <linux/interrupt.h>
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
+#include <linux/of.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/slab.h>
-#include <linux/platform_data/eth-ep93xx.h>
-
#define DRV_MODULE_NAME "ep93xx-eth"
#define RX_QUEUE_ENTRIES 64
@@ -738,25 +737,6 @@ static const struct net_device_ops ep93xx_netdev_ops = {
.ndo_set_mac_address = eth_mac_addr,
};
-static struct net_device *ep93xx_dev_alloc(struct ep93xx_eth_data *data)
-{
- struct net_device *dev;
-
- dev = alloc_etherdev(sizeof(struct ep93xx_priv));
- if (dev == NULL)
- return NULL;
-
- eth_hw_addr_set(dev, data->dev_addr);
-
- dev->ethtool_ops = &ep93xx_ethtool_ops;
- dev->netdev_ops = &ep93xx_netdev_ops;
-
- dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
-
- return dev;
-}
-
-
static int ep93xx_eth_remove(struct platform_device *pdev)
{
struct net_device *dev;
@@ -788,27 +768,51 @@ static int ep93xx_eth_remove(struct platform_device *pdev)
static int ep93xx_eth_probe(struct platform_device *pdev)
{
- struct ep93xx_eth_data *data;
struct net_device *dev;
struct ep93xx_priv *ep;
struct resource *mem;
+ void __iomem *base_addr;
+ struct device_node *np;
+ u32 phy_id;
int irq;
int err;
if (pdev == NULL)
return -ENODEV;
- data = dev_get_platdata(&pdev->dev);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
if (!mem || irq < 0)
return -ENXIO;
- dev = ep93xx_dev_alloc(data);
+ base_addr = ioremap(mem->start, resource_size(mem));
+ if (!base_addr) {
+ dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
+ return -EIO;
+ }
+
+ np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+ if (!np) {
+ dev_err(&pdev->dev, "Please provide \"phy-handle\"\n");
+ return -ENODEV;
+ }
+
+ if (of_property_read_u32(np, "reg", &phy_id)) {
+ dev_err(&pdev->dev, "Failed to locate \"phy_id\"\n");
+ return -ENOENT;
+ }
+
+ dev = alloc_etherdev(sizeof(struct ep93xx_priv));
if (dev == NULL) {
err = -ENOMEM;
goto err_out;
}
+
+ eth_hw_addr_set(dev, base_addr + 0x50);
+ dev->ethtool_ops = &ep93xx_ethtool_ops;
+ dev->netdev_ops = &ep93xx_netdev_ops;
+ dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
+
ep = netdev_priv(dev);
ep->dev = dev;
SET_NETDEV_DEV(dev, &pdev->dev);
@@ -824,15 +828,10 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
goto err_out;
}
- ep->base_addr = ioremap(mem->start, resource_size(mem));
- if (ep->base_addr == NULL) {
- dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
- err = -EIO;
- goto err_out;
- }
+ ep->base_addr = base_addr;
ep->irq = irq;
- ep->mii.phy_id = data->phy_id;
+ ep->mii.phy_id = phy_id;
ep->mii.phy_id_mask = 0x1f;
ep->mii.reg_num_mask = 0x1f;
ep->mii.dev = dev;
@@ -859,12 +858,18 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
return err;
}
+static const struct of_device_id ep93xx_eth_of_ids[] = {
+ { .compatible = "cirrus,ep9301-eth" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ep93xx_eth_of_ids);
static struct platform_driver ep93xx_eth_driver = {
.probe = ep93xx_eth_probe,
.remove = ep93xx_eth_remove,
.driver = {
.name = "ep93xx-eth",
+ .of_match_table = ep93xx_eth_of_ids,
},
};
--
2.37.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx
2023-06-01 5:45 ` [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
@ 2023-06-02 7:27 ` Linus Walleij
2023-06-02 12:09 ` Andrew Lunn
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Linus Walleij @ 2023-06-02 7:27 UTC (permalink / raw)
To: Nikita Shubin
Cc: Alexander Sverdlin, Arnd Bergmann, Hartley Sweeten, Russell King,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Michael Peters, Kris Bahnsen, linux-arm-kernel, linux-kernel,
netdev
On Thu, Jun 1, 2023 at 7:45 AM Nikita Shubin <nikita.shubin@maquefel.me> wrote:
> - find register range from the device tree
> - get "copy_addr" from the device tree
> - get phy_id from the device tree
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Looking really good.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx
2023-06-01 5:45 ` [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
2023-06-02 7:27 ` Linus Walleij
@ 2023-06-02 12:09 ` Andrew Lunn
2023-06-03 20:30 ` andy.shevchenko
2023-06-04 15:51 ` Alexander Sverdlin
3 siblings, 0 replies; 20+ messages in thread
From: Andrew Lunn @ 2023-06-02 12:09 UTC (permalink / raw)
To: Nikita Shubin
Cc: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michael Peters, Kris Bahnsen, linux-arm-kernel,
linux-kernel, netdev
On Thu, Jun 01, 2023 at 08:45:25AM +0300, Nikita Shubin wrote:
> - find register range from the device tree
> - get "copy_addr" from the device tree
> - get phy_id from the device tree
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx
2023-06-01 5:45 ` [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
2023-06-02 7:27 ` Linus Walleij
2023-06-02 12:09 ` Andrew Lunn
@ 2023-06-03 20:30 ` andy.shevchenko
2023-06-04 15:51 ` Alexander Sverdlin
3 siblings, 0 replies; 20+ messages in thread
From: andy.shevchenko @ 2023-06-03 20:30 UTC (permalink / raw)
To: Nikita Shubin
Cc: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michael Peters, Kris Bahnsen, linux-arm-kernel,
linux-kernel, netdev
Thu, Jun 01, 2023 at 08:45:25AM +0300, Nikita Shubin kirjoitti:
> - find register range from the device tree
> - get "copy_addr" from the device tree
> - get phy_id from the device tree
...
> -#include <linux/platform_data/eth-ep93xx.h>
> #include <linux/reboot.h>
> +#include <linux/platform_data/eth-ep93xx.h>
Stray change.
...
> mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> irq = platform_get_irq(pdev, 0);
> if (!mem || irq < 0)
> return -ENXIO;
>
> - dev = ep93xx_dev_alloc(data);
> + base_addr = ioremap(mem->start, resource_size(mem));
> + if (!base_addr) {
> + dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
> + return -EIO;
> + }
Why not switching to devm_platform_ioremap_resource()?
...
> + if (of_property_read_u32(np, "reg", &phy_id)) {
> + dev_err(&pdev->dev, "Failed to locate \"phy_id\"\n");
> + return -ENOENT;
return dev_err_probe(...); ?
> + }
--
With Best Regards,
Andy Shevchenko
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx
2023-06-01 5:45 ` [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
` (2 preceding siblings ...)
2023-06-03 20:30 ` andy.shevchenko
@ 2023-06-04 15:51 ` Alexander Sverdlin
3 siblings, 0 replies; 20+ messages in thread
From: Alexander Sverdlin @ 2023-06-04 15:51 UTC (permalink / raw)
To: Nikita Shubin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Michael Peters, Kris Bahnsen, linux-arm-kernel, linux-kernel,
netdev
Hi!
On Thu, 2023-06-01 at 08:45 +0300, Nikita Shubin wrote:
> - find register range from the device tree
> - get "copy_addr" from the device tree
> - get phy_id from the device tree
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Works fine on EDB9302
Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
>
> Notes:
> v0 -> v1:
>
> - dropped platform data entirely
> - dropped copy_addr
> - use phy-handle instead of using non-conventional phy-id
>
> arch/arm/mach-ep93xx/platform.h | 2 +-
> drivers/net/ethernet/cirrus/ep93xx_eth.c | 67 +++++++++++++-----------
> 2 files changed, 37 insertions(+), 32 deletions(-)
>
> diff --git a/arch/arm/mach-ep93xx/platform.h b/arch/arm/mach-ep93xx/platform.h
> index 5fb1b919133f..3cf2113491d8 100644
> --- a/arch/arm/mach-ep93xx/platform.h
> +++ b/arch/arm/mach-ep93xx/platform.h
> @@ -5,8 +5,8 @@
>
> #ifndef __ASSEMBLY__
>
> -#include <linux/platform_data/eth-ep93xx.h>
> #include <linux/reboot.h>
> +#include <linux/platform_data/eth-ep93xx.h>
>
> struct device;
> struct i2c_board_info;
> diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
> index 8627ab19d470..41096d4830ff 100644
> --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
> +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
> @@ -17,12 +17,11 @@
> #include <linux/interrupt.h>
> #include <linux/moduleparam.h>
> #include <linux/platform_device.h>
> +#include <linux/of.h>
> #include <linux/delay.h>
> #include <linux/io.h>
> #include <linux/slab.h>
>
> -#include <linux/platform_data/eth-ep93xx.h>
> -
> #define DRV_MODULE_NAME "ep93xx-eth"
>
> #define RX_QUEUE_ENTRIES 64
> @@ -738,25 +737,6 @@ static const struct net_device_ops ep93xx_netdev_ops = {
> .ndo_set_mac_address = eth_mac_addr,
> };
>
> -static struct net_device *ep93xx_dev_alloc(struct ep93xx_eth_data *data)
> -{
> - struct net_device *dev;
> -
> - dev = alloc_etherdev(sizeof(struct ep93xx_priv));
> - if (dev == NULL)
> - return NULL;
> -
> - eth_hw_addr_set(dev, data->dev_addr);
> -
> - dev->ethtool_ops = &ep93xx_ethtool_ops;
> - dev->netdev_ops = &ep93xx_netdev_ops;
> -
> - dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
> -
> - return dev;
> -}
> -
> -
> static int ep93xx_eth_remove(struct platform_device *pdev)
> {
> struct net_device *dev;
> @@ -788,27 +768,51 @@ static int ep93xx_eth_remove(struct platform_device *pdev)
>
> static int ep93xx_eth_probe(struct platform_device *pdev)
> {
> - struct ep93xx_eth_data *data;
> struct net_device *dev;
> struct ep93xx_priv *ep;
> struct resource *mem;
> + void __iomem *base_addr;
> + struct device_node *np;
> + u32 phy_id;
> int irq;
> int err;
>
> if (pdev == NULL)
> return -ENODEV;
> - data = dev_get_platdata(&pdev->dev);
>
> mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> irq = platform_get_irq(pdev, 0);
> if (!mem || irq < 0)
> return -ENXIO;
>
> - dev = ep93xx_dev_alloc(data);
> + base_addr = ioremap(mem->start, resource_size(mem));
> + if (!base_addr) {
> + dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
> + return -EIO;
> + }
> +
> + np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
> + if (!np) {
> + dev_err(&pdev->dev, "Please provide \"phy-handle\"\n");
> + return -ENODEV;
> + }
> +
> + if (of_property_read_u32(np, "reg", &phy_id)) {
> + dev_err(&pdev->dev, "Failed to locate \"phy_id\"\n");
> + return -ENOENT;
> + }
> +
> + dev = alloc_etherdev(sizeof(struct ep93xx_priv));
> if (dev == NULL) {
> err = -ENOMEM;
> goto err_out;
> }
> +
> + eth_hw_addr_set(dev, base_addr + 0x50);
> + dev->ethtool_ops = &ep93xx_ethtool_ops;
> + dev->netdev_ops = &ep93xx_netdev_ops;
> + dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
> +
> ep = netdev_priv(dev);
> ep->dev = dev;
> SET_NETDEV_DEV(dev, &pdev->dev);
> @@ -824,15 +828,10 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
> goto err_out;
> }
>
> - ep->base_addr = ioremap(mem->start, resource_size(mem));
> - if (ep->base_addr == NULL) {
> - dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
> - err = -EIO;
> - goto err_out;
> - }
> + ep->base_addr = base_addr;
> ep->irq = irq;
>
> - ep->mii.phy_id = data->phy_id;
> + ep->mii.phy_id = phy_id;
> ep->mii.phy_id_mask = 0x1f;
> ep->mii.reg_num_mask = 0x1f;
> ep->mii.dev = dev;
> @@ -859,12 +858,18 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
> return err;
> }
>
> +static const struct of_device_id ep93xx_eth_of_ids[] = {
> + { .compatible = "cirrus,ep9301-eth" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, ep93xx_eth_of_ids);
>
> static struct platform_driver ep93xx_eth_driver = {
> .probe = ep93xx_eth_probe,
> .remove = ep93xx_eth_remove,
> .driver = {
> .name = "ep93xx-eth",
> + .of_match_table = ep93xx_eth_of_ids,
> },
> };
>
--
Alexander Sverdlin.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1 22/43] dma: cirrus: add DT support for Cirrus EP93xx
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
` (4 preceding siblings ...)
2023-06-01 5:45 ` [PATCH v1 20/43] net: cirrus: add DT support for Cirrus EP93xx Nikita Shubin
@ 2023-06-01 5:45 ` Nikita Shubin
2023-06-03 20:39 ` andy.shevchenko
2023-06-01 5:45 ` [PATCH v1 35/43] ARM: dts: add device tree for ep93xx Soc Nikita Shubin
2023-06-01 5:45 ` [PATCH v1 36/43] ARM: ep93xx: DT for the Cirrus ep93xx SoC platforms Nikita Shubin
7 siblings, 1 reply; 20+ messages in thread
From: Nikita Shubin @ 2023-06-01 5:45 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, Vinod Koul, Nikita Shubin
Cc: Michael Peters, Kris Bahnsen, linux-arm-kernel, linux-kernel,
dmaengine
- find register range from the device tree
- get clocks, interrupts from device tree
Co-developed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
arch/arm/mach-ep93xx/dma.c | 1 +
drivers/dma/ep93xx_dma.c | 136 +++++++++++++++++++++--
include/linux/platform_data/dma-ep93xx.h | 3 +
3 files changed, 130 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-ep93xx/dma.c b/arch/arm/mach-ep93xx/dma.c
index 74515acab8ef..273954cbfced 100644
--- a/arch/arm/mach-ep93xx/dma.c
+++ b/arch/arm/mach-ep93xx/dma.c
@@ -19,6 +19,7 @@
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/platform_data/dma-ep93xx.h>
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index 5338a94f1a69..9f71e08ca380 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -20,6 +20,7 @@
#include <linux/dmaengine.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -104,6 +105,11 @@
#define DMA_MAX_CHAN_BYTES 0xffff
#define DMA_MAX_CHAN_DESCRIPTORS 32
+enum ep93xx_dma_type {
+ M2P_DMA,
+ M2M_DMA,
+};
+
struct ep93xx_dma_engine;
static int ep93xx_dma_slave_config_write(struct dma_chan *chan,
enum dma_transfer_direction dir,
@@ -213,7 +219,7 @@ struct ep93xx_dma_engine {
#define INTERRUPT_NEXT_BUFFER 2
size_t num_channels;
- struct ep93xx_dma_chan channels[];
+ struct ep93xx_dma_chan *channels;
};
static inline struct device *chan2dev(struct ep93xx_dma_chan *edmac)
@@ -875,9 +881,11 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
if (!edmac->edma->m2m) {
if (!data)
return -EINVAL;
+
if (data->port < EP93XX_DMA_I2S1 ||
data->port > EP93XX_DMA_IRDA)
return -EINVAL;
+
if (data->direction != ep93xx_dma_chan_direction(chan))
return -EINVAL;
} else {
@@ -1315,20 +1323,105 @@ static void ep93xx_dma_issue_pending(struct dma_chan *chan)
ep93xx_dma_advance_work(to_ep93xx_dma_chan(chan));
}
-static int __init ep93xx_dma_probe(struct platform_device *pdev)
+
+#ifdef CONFIG_OF
+struct ep93xx_edma_data {
+ u32 id;
+ size_t num_channels;
+};
+
+static const struct ep93xx_edma_data edma_m2p = {
+ .id = M2P_DMA,
+ .num_channels = 10,
+};
+
+static const struct ep93xx_edma_data edma_m2m = {
+ .id = M2M_DMA,
+ .num_channels = 2,
+};
+
+static const struct of_device_id ep93xx_dma_of_ids[] = {
+ { .compatible = "cirrus,ep9301-dma-m2p", .data = &edma_m2p },
+ { .compatible = "cirrus,ep9301-dma-m2m", .data = &edma_m2m },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ep93xx_dma_of_ids);
+
+static int ep93xx_dma_of_probe(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
+{
+ struct device_node *np = pdev->dev.of_node;
+ const struct of_device_id *match = of_match_node(ep93xx_dma_of_ids, pdev->dev.of_node);
+ const struct ep93xx_edma_data *data = match->data;
+ struct dma_device *dma_dev = &edma->dma_dev;
+ int num_channels;
+ int i;
+
+ match = of_match_device((ep93xx_dma_of_ids), &pdev->dev);
+ if (!match || !match->data) {
+ dev_err(&pdev->dev, "No device match found\n");
+ return -ENODEV;
+ }
+
+ edma->m2m = data->id;
+ num_channels = data->num_channels;
+ edma->channels = devm_kzalloc(&pdev->dev,
+ num_channels * sizeof(struct ep93xx_dma_chan),
+ GFP_KERNEL);
+ if (!edma->channels)
+ return -ENOMEM;
+
+ edma->num_channels = num_channels;
+
+ INIT_LIST_HEAD(&dma_dev->channels);
+ for (i = 0; i < num_channels; i++) {
+ struct ep93xx_dma_chan *edmac = &edma->channels[i];
+
+ edmac->chan.device = dma_dev;
+ edmac->regs = devm_platform_ioremap_resource(pdev, i);
+ edmac->irq = platform_get_irq(pdev, i);
+ edmac->edma = edma;
+
+ edmac->clk = of_clk_get(np, i);
+
+ if (IS_ERR(edmac->clk)) {
+ dev_warn(&pdev->dev, "failed to get clock\n");
+ continue;
+ }
+
+ spin_lock_init(&edmac->lock);
+ INIT_LIST_HEAD(&edmac->active);
+ INIT_LIST_HEAD(&edmac->queue);
+ INIT_LIST_HEAD(&edmac->free_list);
+ tasklet_setup(&edmac->tasklet, ep93xx_dma_tasklet);
+
+ list_add_tail(&edmac->chan.device_node,
+ &dma_dev->channels);
+ }
+
+ return 0;
+}
+#else
+static int ep93xx_dma_of_probe(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
+{
+ return -EINVAL;
+}
+#endif
+
+static int ep93xx_init_from_pdata(struct platform_device *pdev,
+ struct ep93xx_dma_engine *edma)
{
struct ep93xx_dma_platform_data *pdata = dev_get_platdata(&pdev->dev);
- struct ep93xx_dma_engine *edma;
- struct dma_device *dma_dev;
- size_t edma_size;
- int ret, i;
+ struct dma_device *dma_dev = &edma->dma_dev;
+ int i;
- edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan);
- edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL);
- if (!edma)
+ edma->channels = devm_kzalloc(&pdev->dev,
+ pdata->num_channels * sizeof(struct ep93xx_dma_chan),
+ GFP_KERNEL);
+ if (!edma->channels)
return -ENOMEM;
- dma_dev = &edma->dma_dev;
edma->m2m = platform_get_device_id(pdev)->driver_data;
edma->num_channels = pdata->num_channels;
@@ -1359,6 +1452,27 @@ static int __init ep93xx_dma_probe(struct platform_device *pdev)
&dma_dev->channels);
}
+ return 0;
+}
+
+static int __init ep93xx_dma_probe(struct platform_device *pdev)
+{
+ struct ep93xx_dma_engine *edma;
+ struct dma_device *dma_dev;
+ int ret, i;
+
+ edma = devm_kzalloc(&pdev->dev, sizeof(*edma), GFP_KERNEL);
+
+ if (platform_get_device_id(pdev))
+ ret = ep93xx_init_from_pdata(pdev, edma);
+ else
+ ret = ep93xx_dma_of_probe(pdev, edma);
+
+ if (ret)
+ return ret;
+
+ dma_dev = &edma->dma_dev;
+
dma_cap_zero(dma_dev->cap_mask);
dma_cap_set(DMA_SLAVE, dma_dev->cap_mask);
dma_cap_set(DMA_CYCLIC, dma_dev->cap_mask);
@@ -1415,10 +1529,12 @@ static const struct platform_device_id ep93xx_dma_driver_ids[] = {
{ "ep93xx-dma-m2m", 1 },
{ },
};
+MODULE_DEVICE_TABLE(of, ep93xx_dma_driver_ids);
static struct platform_driver ep93xx_dma_driver = {
.driver = {
.name = "ep93xx-dma",
+ .of_match_table = ep93xx_dma_of_ids,
},
.id_table = ep93xx_dma_driver_ids,
};
diff --git a/include/linux/platform_data/dma-ep93xx.h b/include/linux/platform_data/dma-ep93xx.h
index eb9805bb3fe8..d485e3c21a3a 100644
--- a/include/linux/platform_data/dma-ep93xx.h
+++ b/include/linux/platform_data/dma-ep93xx.h
@@ -70,6 +70,9 @@ struct ep93xx_dma_platform_data {
static inline bool ep93xx_dma_chan_is_m2p(struct dma_chan *chan)
{
+ if (of_device_is_compatible(dev_of_node(chan->device->dev), "cirrus,ep9301-dma-m2p"))
+ return true;
+
return !strcmp(dev_name(chan->device->dev), "ep93xx-dma-m2p");
}
--
2.37.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v1 22/43] dma: cirrus: add DT support for Cirrus EP93xx
2023-06-01 5:45 ` [PATCH v1 22/43] dma: " Nikita Shubin
@ 2023-06-03 20:39 ` andy.shevchenko
0 siblings, 0 replies; 20+ messages in thread
From: andy.shevchenko @ 2023-06-03 20:39 UTC (permalink / raw)
To: Nikita Shubin
Cc: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Hartley Sweeten,
Russell King, Vinod Koul, Michael Peters, Kris Bahnsen,
linux-arm-kernel, linux-kernel, dmaengine
Thu, Jun 01, 2023 at 08:45:27AM +0300, Nikita Shubin kirjoitti:
> - find register range from the device tree
> - get clocks, interrupts from device tree
...
> --- a/arch/arm/mach-ep93xx/dma.c
> +++ b/arch/arm/mach-ep93xx/dma.c
> @@ -19,6 +19,7 @@
> #include <linux/init.h>
> #include <linux/interrupt.h>
> #include <linux/kernel.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
>
> #include <linux/platform_data/dma-ep93xx.h>
Stray change.
...
> --- a/drivers/dma/ep93xx_dma.c
> +++ b/drivers/dma/ep93xx_dma.c
> @@ -20,6 +20,7 @@
> #include <linux/dmaengine.h>
> #include <linux/module.h>
> #include <linux/mod_devicetable.h>
> +#include <linux/of_device.h>
> #include <linux/platform_device.h>
> #include <linux/slab.h>
...
> - struct ep93xx_dma_chan channels[];
> + struct ep93xx_dma_chan *channels;
Why? This is helpful to allocate main structure and channels in one go.
...
> @@ -875,9 +881,11 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
> if (!edmac->edma->m2m) {
> if (!data)
> return -EINVAL;
> +
> if (data->port < EP93XX_DMA_I2S1 ||
> data->port > EP93XX_DMA_IRDA)
> return -EINVAL;
> +
> if (data->direction != ep93xx_dma_chan_direction(chan))
> return -EINVAL;
> } else {
Seems unrelated change.
> ep93xx_dma_advance_work(to_ep93xx_dma_chan(chan));
> }
...
> +static const struct of_device_id ep93xx_dma_of_ids[] = {
> + { .compatible = "cirrus,ep9301-dma-m2p", .data = &edma_m2p },
> + { .compatible = "cirrus,ep9301-dma-m2m", .data = &edma_m2m },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, ep93xx_dma_of_ids);
Move this closer to the real user (see below).
Also this ID table shouldn't be under ifdeffery.
...
> + struct device_node *np = pdev->dev.of_node;
> + const struct of_device_id *match = of_match_node(ep93xx_dma_of_ids, pdev->dev.of_node);
> + const struct ep93xx_edma_data *data = match->data;
No NULL check? Why do you have this duplication, btw?
> + struct dma_device *dma_dev = &edma->dma_dev;
> + int num_channels;
> + int i;
> +
> + match = of_match_device((ep93xx_dma_of_ids), &pdev->dev);
> + if (!match || !match->data) {
> + dev_err(&pdev->dev, "No device match found\n");
> + return -ENODEV;
> + }
Use of_device_get_match_data().
...
> + edma->channels = devm_kzalloc(&pdev->dev,
> + num_channels * sizeof(struct ep93xx_dma_chan),
> + GFP_KERNEL);
> + if (!edma->channels)
> + return -ENOMEM;
Simply no. See below what to do.
...
> + for (i = 0; i < num_channels; i++) {
> + struct ep93xx_dma_chan *edmac = &edma->channels[i];
> +
> + edmac->chan.device = dma_dev;
> + edmac->regs = devm_platform_ioremap_resource(pdev, i);
No error check?
> + edmac->irq = platform_get_irq(pdev, i);
No error check?
> + edmac->edma = edma;
> +
> + edmac->clk = of_clk_get(np, i);
Can this actually use clk_get() or its devm_*() variant?
> +
Redundant blank line.
> + if (IS_ERR(edmac->clk)) {
> + dev_warn(&pdev->dev, "failed to get clock\n");
> + continue;
> + }
> +
> + spin_lock_init(&edmac->lock);
> + INIT_LIST_HEAD(&edmac->active);
> + INIT_LIST_HEAD(&edmac->queue);
> + INIT_LIST_HEAD(&edmac->free_list);
> + tasklet_setup(&edmac->tasklet, ep93xx_dma_tasklet);
> +
> + list_add_tail(&edmac->chan.device_node,
> + &dma_dev->channels);
> + }
...
> - edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan);
> - edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL);
> - if (!edma)
> + edma->channels = devm_kzalloc(&pdev->dev,
> + pdata->num_channels * sizeof(struct ep93xx_dma_chan),
> + GFP_KERNEL);
> + if (!edma->channels)
> return -ENOMEM;
No. Just include overflow.h and use struct_size().
...
> + edma = devm_kzalloc(&pdev->dev, sizeof(*edma), GFP_KERNEL);
> +
No error check?!
...
> + if (platform_get_device_id(pdev))
> + ret = ep93xx_init_from_pdata(pdev, edma);
> + else
> + ret = ep93xx_dma_of_probe(pdev, edma);
> +
Redundant blank line.
> + if (ret)
> + return ret;
--
With Best Regards,
Andy Shevchenko
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1 35/43] ARM: dts: add device tree for ep93xx Soc
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
` (5 preceding siblings ...)
2023-06-01 5:45 ` [PATCH v1 22/43] dma: " Nikita Shubin
@ 2023-06-01 5:45 ` Nikita Shubin
2023-06-01 8:30 ` Krzysztof Kozlowski
2023-06-01 5:45 ` [PATCH v1 36/43] ARM: ep93xx: DT for the Cirrus ep93xx SoC platforms Nikita Shubin
7 siblings, 1 reply; 20+ messages in thread
From: Nikita Shubin @ 2023-06-01 5:45 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Olof Johansson,
soc, Rob Herring, Krzysztof Kozlowski
Cc: Nikita Shubin, Michael Peters, Kris Bahnsen, linux-arm-kernel,
devicetree, linux-kernel
This adds a divice for Cirrus ep93xx SoC amd ts7250 board that has been
my testing target for ep93xx device support.
Also inluded device tree for Liebherr BK3.1 board through it's not a
complete support.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
Notes:
v0 -> v1:
- add empty chosen node
- s/dallas,rtc-m48t86/st,m48t86/
- changed phy_id to phy-handle
- dropped gpio chip-label's
- s/eth@80010000/ethernet@80010000
- s/use_dma/ep9301,use-dma
- added i2s to bk3
arch/arm/boot/dts/Makefile | 1 +
arch/arm/boot/dts/ep93xx-bk3.dts | 119 +++++++
arch/arm/boot/dts/ep93xx-ts7250.dts | 132 ++++++++
arch/arm/boot/dts/ep93xx.dtsi | 466 ++++++++++++++++++++++++++++
4 files changed, 718 insertions(+)
create mode 100644 arch/arm/boot/dts/ep93xx-bk3.dts
create mode 100644 arch/arm/boot/dts/ep93xx-ts7250.dts
create mode 100644 arch/arm/boot/dts/ep93xx.dtsi
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 59829fc90315..a68f868fffe7 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -1670,3 +1670,4 @@ dtb-$(CONFIG_ARCH_ASPEED) += \
aspeed-bmc-vegman-n110.dtb \
aspeed-bmc-vegman-rx20.dtb \
aspeed-bmc-vegman-sx20.dtb
+dtb-$(CONFIG_ARCH_EP93XX) += ep93xx-ts7250.dtb
diff --git a/arch/arm/boot/dts/ep93xx-bk3.dts b/arch/arm/boot/dts/ep93xx-bk3.dts
new file mode 100644
index 000000000000..215587c498e6
--- /dev/null
+++ b/arch/arm/boot/dts/ep93xx-bk3.dts
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree file for Liebherr controller BK3.1 based on Cirrus EP9302 SoC
+ */
+/dts-v1/;
+#include "ep93xx.dtsi"
+
+/ {
+ model = "Liebherr controller BK3.1";
+ compatible = "liebherr,bk3", "cirrus,ep9301";
+
+ chosen {
+ };
+
+ memory {
+ device_type = "memory";
+ };
+
+ soc {
+ nand-controller@60000000 {
+ compatible = "technologic,ts7200-nand";
+ reg = <0x60000000 0x8000000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "System";
+ reg = <0x00000000 0x01e00000>;
+ read-only;
+ };
+
+ partition@1e00000 {
+ label = "Data";
+ reg = <0x01e00000 0x05f20000>;
+ };
+
+ partition@7d20000 {
+ label = "RedBoot";
+ reg = <0x07d20000 0x002e0000>;
+ read-only;
+ };
+ };
+ };
+
+ syscon: syscon@80930000 {
+ pinctrl: pinctrl {
+ compatible = "cirrus,ep9301-pinctrl";
+ };
+ };
+
+ gpio1: gpio@80840004 {
+ /* PWM */
+ gpio-ranges = <&pinctrl 6 163 1>;
+ };
+ };
+};
+
+&gpio1 {
+ /* PWM */
+ gpio-ranges = <&pinctrl 6 163 1>;
+};
+
+&gpio4 {
+ gpio-ranges = <&pinctrl 0 97 2>;
+ status = "okay";
+};
+
+&gpio6 {
+ gpio-ranges = <&pinctrl 0 87 2>;
+ status = "okay";
+};
+
+&gpio7 {
+ gpio-ranges = <&pinctrl 2 199 4>;
+ status = "okay";
+};
+
+&i2c {
+ status = "okay";
+};
+
+&spi0: spi@808a0000 {
+ cs-gpios = <&gpio5 3 0>;
+ status = "okay";
+};
+
+ð0 {
+ phy-handle = <&phy0>;
+};
+
+&mdio0 {
+ phy0: ethernet-phy@1 {
+ reg = <1>;
+ device_type = "ethernet-phy";
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&uart1 {
+ status = "okay";
+};
+
+&usb {
+ status = "okay";
+};
+
+&i2s {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2s_on_ac97_pins>;
+ /delete-property/ status;
+};
diff --git a/arch/arm/boot/dts/ep93xx-ts7250.dts b/arch/arm/boot/dts/ep93xx-ts7250.dts
new file mode 100644
index 000000000000..40290e3cb9b3
--- /dev/null
+++ b/arch/arm/boot/dts/ep93xx-ts7250.dts
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree file for Technologic Systems ts7250 board based on Cirrus EP9302 SoC
+ */
+/dts-v1/;
+#include "ep93xx.dtsi"
+
+/ {
+ compatible = "technologic,ts7250", "cirrus,ep9301";
+ model = "TS-7250 SBC";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ chosen {
+ };
+
+ memory@0 {
+ device_type = "memory";
+ /* should be set from ATAGS */
+ reg = <0x00000000 0x02000000>,
+ <0x000530c0 0x01fdd000>;
+ };
+
+ soc {
+ nand-controller@60000000 {
+ compatible = "technologic,ts7200-nand";
+ reg = <0x60000000 0x8000000>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "TS-BOOTROM";
+ reg = <0x00000000 0x00020000>;
+ read-only;
+ };
+
+ partition@20000 {
+ label = "Linux";
+ reg = <0x00020000 0x07d00000>;
+ };
+
+ partition@7d20000 {
+ label = "RedBoot";
+ reg = <0x07d20000 0x002e0000>;
+ read-only;
+ };
+ };
+ };
+
+ syscon: syscon@80930000 {
+ pinctrl: pinctrl {
+ compatible = "cirrus,ep9301-pinctrl";
+ };
+ };
+
+ rtc1: rtc@10800000 {
+ compatible = "st,m48t86";
+ reg = <0x10800000 0x1>,
+ <0x11700000 0x1>;
+ };
+
+ watchdog1: watchdog@23800000 {
+ compatible = "technologic,ts7200-wdt";
+ reg = <0x23800000 0x01>,
+ <0x23c00000 0x01>;
+ timeout-sec = <30>;
+ };
+ };
+};
+
+&gpio1 {
+ /* PWM */
+ gpio-ranges = <&pinctrl 6 163 1>;
+};
+
+&gpio4 {
+ gpio-ranges = <&pinctrl 0 97 2>;
+ status = "okay";
+};
+
+&gpio6 {
+ gpio-ranges = <&pinctrl 0 87 2>;
+ status = "okay";
+};
+
+&gpio7 {
+ gpio-ranges = <&pinctrl 2 199 4>;
+ status = "okay";
+};
+
+&i2c0 {
+ status = "okay";
+};
+
+&spi0 {
+ cs-gpios = <&gpio5 2 0>;
+ status = "okay";
+
+ tmp122_spi: tmp122@0 {
+ compatible = "ti,tmp122";
+ reg = <0>;
+ spi-max-frequency = <2000000>;
+ };
+};
+
+ð0 {
+ phy-handle = <&phy0>;
+};
+
+&mdio0 {
+ phy0: ethernet-phy@1 {
+ reg = <1>;
+ device_type = "ethernet-phy";
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&uart1 {
+ status = "okay";
+};
+
+&usb0 {
+ status = "okay";
+};
diff --git a/arch/arm/boot/dts/ep93xx.dtsi b/arch/arm/boot/dts/ep93xx.dtsi
new file mode 100644
index 000000000000..6da556ceaf04
--- /dev/null
+++ b/arch/arm/boot/dts/ep93xx.dtsi
@@ -0,0 +1,466 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree file for Cirrus Logic systems EP93XX SoC
+ */
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/clock/cirrus,ep93xx-clock.h>
+/ {
+ soc {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+ compatible = "simple-bus";
+
+ syscon: syscon@80930000 {
+ compatible = "cirrus,ep9301-syscon",
+ "syscon", "simple-mfd";
+ reg = <0x80930000 0x1000>;
+
+ ep9301-reboot {
+ compatible = "cirrus,ep9301-reboot";
+ };
+
+ eclk: clock-controller {
+ #clock-cells = <1>;
+ compatible = "cirrus,ep9301-clk";
+ status = "okay";
+ clocks = <&xtali>;
+ };
+
+ pinctrl: pinctrl {
+ spi_default_pins: pins-spi {
+ function = "spi";
+ groups = "ssp";
+ };
+
+ ac97_default_pins: pins-ac97 {
+ function = "ac97";
+ groups = "ac97";
+ };
+
+ i2s_on_ssp_pins: pins-i2sonssp {
+ function = "i2s";
+ groups = "i2s_on_ssp";
+ };
+
+ i2s_on_ac97_pins: pins-i2sonac97 {
+ function = "i2s";
+ groups = "i2s_on_ac97";
+ };
+
+ gpio1_default_pins: pins-gpio1 {
+ function = "gpio";
+ groups = "gpio1agrp";
+ };
+
+ pwm1_default_pins: pins-pwm1 {
+ function = "pwm";
+ groups = "pwm1";
+ };
+
+ gpio2_default_pins: pins-gpio2 {
+ function = "gpio";
+ groups = "gpio2agrp";
+ };
+
+ gpio3_default_pins: pins-gpio3 {
+ function = "gpio";
+ groups = "gpio3agrp";
+ };
+
+ keypad_default_pins: pins-keypad {
+ function = "keypad";
+ groups = "keypadgrp";
+ };
+
+ gpio4_default_pins: pins-gpio4 {
+ function = "gpio";
+ groups = "gpio4agrp";
+ };
+
+ gpio6_default_pins: pins-gpio6 {
+ function = "gpio";
+ groups = "gpio6agrp";
+ };
+
+ gpio7_default_pins: pins-gpio7 {
+ function = "gpio";
+ groups = "gpio7agrp";
+ };
+
+ ide_default_pins: pins-ide {
+ function = "pata";
+ groups = "idegrp";
+ };
+
+ lcd_on_dram0_pins: pins-rasteronsdram0 {
+ function = "lcd";
+ groups = "rasteronsdram0grp";
+ };
+
+ lcd_on_dram3_pins: pins-rasteronsdram3 {
+ function = "lcd";
+ groups = "rasteronsdram3grp";
+ };
+ };
+ };
+
+ vic0: interrupt-controller@800b0000 {
+ compatible = "arm,pl192-vic";
+ interrupt-controller;
+ reg = <0x800b0000 0x1000>;
+ #interrupt-cells = <1>;
+ valid-mask = <0x7ffffffc>;
+ valid-wakeup-mask = <0x0>;
+ };
+
+ vic1: interrupt-controller@800c0000 {
+ compatible = "arm,pl192-vic";
+ interrupt-controller;
+ reg = <0x800c0000 0x1000>;
+ #interrupt-cells = <1>;
+ valid-mask = <0x1fffffff>;
+ valid-wakeup-mask = <0x0>;
+ };
+
+ timer: timer@80810000 {
+ compatible = "cirrus,ep9301-timer";
+ reg = <0x80810000 0x100>;
+ interrupt-parent = <&vic1>;
+ interrupts = <19>;
+ };
+
+ dma0: dma-controller@80000000 {
+ compatible = "cirrus,ep9301-dma-m2p";
+ reg = <0x80000000 0x0040>,
+ <0x80000040 0x0040>,
+ <0x80000080 0x0040>,
+ <0x800000c0 0x0040>,
+ <0x80000240 0x0040>,
+ <0x80000200 0x0040>,
+ <0x800002c0 0x0040>,
+ <0x80000280 0x0040>,
+ <0x80000340 0x0040>,
+ <0x80000300 0x0040>;
+ clocks = <&eclk EP93XX_CLK_M2P0>,
+ <&eclk EP93XX_CLK_M2P1>,
+ <&eclk EP93XX_CLK_M2P2>,
+ <&eclk EP93XX_CLK_M2P3>,
+ <&eclk EP93XX_CLK_M2P4>,
+ <&eclk EP93XX_CLK_M2P5>,
+ <&eclk EP93XX_CLK_M2P6>,
+ <&eclk EP93XX_CLK_M2P7>,
+ <&eclk EP93XX_CLK_M2P8>,
+ <&eclk EP93XX_CLK_M2P9>;
+ clock-names = "m2p0", "m2p1",
+ "m2p2", "m2p3",
+ "m2p4", "m2p5",
+ "m2p6", "m2p7",
+ "m2p8", "m2p9";
+ interrupt-parent = <&vic0>;
+ interrupts = <7>, <8>, <9>, <10>, <11>,
+ <12>, <13>, <14>, <15>, <16>;
+ #dma-cells = <1>;
+ };
+
+ dma1: dma-controller@80000100 {
+ compatible = "cirrus,ep9301-dma-m2m";
+ reg = <0x80000100 0x0040>,
+ <0x80000140 0x0040>;
+ clocks = <&eclk EP93XX_CLK_M2M0>,
+ <&eclk EP93XX_CLK_M2M1>;
+ clock-names = "m2m0", "m2m1";
+ interrupt-parent = <&vic0>;
+ interrupts = <17>, <18>;
+ #dma-cells = <1>;
+ };
+
+ i2s: i2s@80820000 {
+ compatible = "cirrus,ep9301-i2s";
+ #sound-dai-cells = <0>;
+ reg = <0x80820000 0x100>;
+ interrupt-parent = <&vic1>;
+ interrupts = <28>;
+ clocks = <&eclk EP93XX_CLK_I2S_MCLK
+ &eclk EP93XX_CLK_I2S_SCLK
+ &eclk EP93XX_CLK_I2S_LRCLK>;
+ clock-names = "mclk", "sclk", "lrclk";
+ status = "disabled";
+ };
+
+ gpio0: gpio@80840000 {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x80840000 0x04>,
+ <0x80840010 0x04>,
+ <0x80840090 0x1c>;
+ reg-names = "data", "dir", "intr";
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ interrupt-parent = <&vic1>;
+ interrupts = <27>;
+ };
+
+ gpio1: gpio@80840004 {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x80840004 0x04>,
+ <0x80840014 0x04>,
+ <0x808400ac 0x1c>;
+ reg-names = "data", "dir", "intr";
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ interrupt-parent = <&vic1>;
+ interrupts = <27>;
+ };
+
+ gpio2: gpio@80840008 {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x80840008 0x04>,
+ <0x80840018 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio2_default_pins>;
+ };
+
+ gpio3: gpio@8084000c {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x8084000c 0x04>,
+ <0x8084001c 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio3_default_pins>;
+ };
+
+ gpio4: gpio@80840020 {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x80840020 0x04>,
+ <0x80840024 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio4_default_pins>;
+ };
+
+ gpio5: gpio@80840030 {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x80840030 0x04>,
+ <0x80840034 0x04>,
+ <0x8084004c 0x1c>;
+ reg-names = "data", "dir", "intr";
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ interrupts-extended = <&vic0 19>, <&vic0 20>,
+ <&vic0 21>, <&vic0 22>,
+ <&vic1 15>, <&vic1 16>,
+ <&vic1 17>, <&vic1 18>;
+ };
+
+ gpio6: gpio@80840038 {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x80840038 0x04>,
+ <0x8084003c 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio6_default_pins>;
+ };
+
+ gpio7: gpio@80840040 {
+ compatible = "cirrus,ep9301-gpio";
+ reg = <0x80840040 0x04>,
+ <0x80840044 0x04>;
+ reg-names = "data", "dir";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio7_default_pins>;
+ };
+
+ ide: ide@800a0000 {
+ compatible = "cirrus,ep9312-pata";
+ reg = <0x800a0000 0x38>;
+ interrupt-parent = <&vic1>;
+ interrupts = <8>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&ide_default_pins>;
+ };
+
+ uart0: uart@808c0000 {
+ compatible = "arm,primecell";
+ reg = <0x808c0000 0x1000>;
+ arm,primecell-periphid = <0x00041010>;
+ clocks = <&eclk EP93XX_CLK_UART1>, <&eclk EP93XX_CLK_UART>;
+ clock-names = "apb:uart1", "apb_pclk";
+ interrupt-parent = <&vic1>;
+ interrupts = <20>;
+ status = "disabled";
+ };
+
+ uart1: uart@808d0000 {
+ compatible = "arm,primecell";
+ reg = <0x808d0000 0x1000>;
+ arm,primecell-periphid = <0x00041010>;
+ clocks = <&eclk EP93XX_CLK_UART2>, <&eclk EP93XX_CLK_UART>;
+ clock-names = "apb:uart2", "apb_pclk";
+ interrupt-parent = <&vic1>;
+ interrupts = <22>;
+ status = "disabled";
+ };
+
+ uart2: uart@808b0000 {
+ compatible = "arm,primecell";
+ reg = <0x808b0000 0x1000>;
+ arm,primecell-periphid = <0x00041010>;
+ clocks = <&eclk EP93XX_CLK_UART3>, <&eclk EP93XX_CLK_UART>;
+ clock-names = "apb:uart3", "apb_pclk";
+ interrupt-parent = <&vic1>;
+ interrupts = <23>;
+ status = "disabled";
+ };
+
+ usb0: usb@80020000 {
+ compatible = "generic-ohci";
+ reg = <0x80020000 0x10000>;
+ interrupt-parent = <&vic1>;
+ interrupts = <24>;
+ clocks = <&eclk EP93XX_CLK_USB>;
+ status = "disabled";
+ };
+
+ eth0: ethernet@80010000 {
+ compatible = "cirrus,ep9301-eth";
+ reg = <0x80010000 0x10000>;
+ interrupt-parent = <&vic1>;
+ interrupts = <7>;
+ mdio0: mdio {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+ };
+
+ rtc0: rtc@80920000 {
+ compatible = "cirrus,ep9301-rtc";
+ reg = <0x80920000 0x100>;
+ };
+
+ spi0: spi@808a0000 {
+ compatible = "cirrus,ep9301-spi";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x808a0000 0x18>;
+ interrupt-parent = <&vic1>;
+ interrupts = <21>;
+ clocks = <&eclk EP93XX_CLK_SPI>;
+ cs-gpios = <&gpio5 2 0>;
+ cirrus,ep9301-use-dma;
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi_default_pins>;
+ status = "disabled";
+ };
+
+ adc: adc@80900000 {
+ compatible = "cirrus,ep9301-adc";
+ reg = <0x80900000 0x28>;
+ clocks = <&eclk EP93XX_CLK_ADC>;
+ interrupt-parent = <&vic0>;
+ interrupts = <30>;
+ status = "disabled";
+ };
+
+ watchdog0: watchdog@80940000 {
+ compatible = "cirrus,ep9301-wdt";
+ reg = <0x80940000 0x08>;
+ };
+
+ pwm0: pwm@80910000 {
+ compatible = "cirrus,ep9301-pwm";
+ reg = <0x80910000 0x10>;
+ clocks = <&eclk EP93XX_CLK_PWM>;
+ status = "disabled";
+ };
+
+ pwm1: pwm@80910020 {
+ compatible = "cirrus,ep9301-pwm";
+ reg = <0x80910020 0x10>;
+ clocks = <&eclk EP93XX_CLK_PWM>;
+ status = "disabled";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm1_default_pins>;
+ };
+
+ keypad: keypad@800f0000 {
+ compatible = "cirrus,ep9307-keypad";
+ reg = <0x800f0000 0x0c>;
+ interrupt-parent = <&vic0>;
+ interrupts = <29>;
+ clocks = <&eclk EP93XX_CLK_KEYPAD>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&keypad_default_pins>;
+ linux,keymap =
+ <KEY_UP>,
+ <KEY_DOWN>,
+ <KEY_VOLUMEDOWN>,
+ <KEY_HOME>,
+ <KEY_RIGHT>,
+ <KEY_LEFT>,
+ <KEY_ENTER>,
+ <KEY_VOLUMEUP>,
+ <KEY_F6>,
+ <KEY_F8>,
+ <KEY_F9>,
+ <KEY_F10>,
+ <KEY_F1>,
+ <KEY_F2>,
+ <KEY_F3>,
+ <KEY_POWER>;
+ };
+ };
+
+ xtali: oscillator {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <14745600>;
+ clock-output-names = "xtali";
+ };
+
+ i2c0: i2c0 {
+ compatible = "i2c-gpio";
+ sda-gpios = <&gpio6 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+ scl-gpios = <&gpio6 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
+ leds {
+ compatible = "gpio-leds";
+ led0 {
+ label = "grled";
+ gpios = <&gpio4 0 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "heartbeat";
+ function = LED_FUNCTION_HEARTBEAT;
+ };
+
+ led1 {
+ label = "rdled";
+ gpios = <&gpio4 1 GPIO_ACTIVE_HIGH>;
+ function = LED_FUNCTION_FAULT;
+ };
+ };
+};
--
2.37.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v1 35/43] ARM: dts: add device tree for ep93xx Soc
2023-06-01 5:45 ` [PATCH v1 35/43] ARM: dts: add device tree for ep93xx Soc Nikita Shubin
@ 2023-06-01 8:30 ` Krzysztof Kozlowski
2023-07-05 16:06 ` Nikita Shubin
0 siblings, 1 reply; 20+ messages in thread
From: Krzysztof Kozlowski @ 2023-06-01 8:30 UTC (permalink / raw)
To: Nikita Shubin, Alexander Sverdlin, Arnd Bergmann, Linus Walleij,
Olof Johansson, soc, Rob Herring, Krzysztof Kozlowski
Cc: Michael Peters, Kris Bahnsen, linux-arm-kernel, devicetree,
linux-kernel
On 01/06/2023 07:45, Nikita Shubin wrote:
> This adds a divice for Cirrus ep93xx SoC amd ts7250 board that has been
device
> my testing target for ep93xx device support.
>
> Also inluded device tree for Liebherr BK3.1 board through it's not a
included
> complete support.
Thank you for your patch. There is something to discuss/improve.
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
> ---
>
> Notes:
> v0 -> v1:
>
> - add empty chosen node
> - s/dallas,rtc-m48t86/st,m48t86/
> - changed phy_id to phy-handle
> - dropped gpio chip-label's
> - s/eth@80010000/ethernet@80010000
> - s/use_dma/ep9301,use-dma
> - added i2s to bk3
>
> arch/arm/boot/dts/Makefile | 1 +
> arch/arm/boot/dts/ep93xx-bk3.dts | 119 +++++++
> arch/arm/boot/dts/ep93xx-ts7250.dts | 132 ++++++++
> arch/arm/boot/dts/ep93xx.dtsi | 466 ++++++++++++++++++++++++++++
Split adding DTSI from adding boards.
> 4 files changed, 718 insertions(+)
> create mode 100644 arch/arm/boot/dts/ep93xx-bk3.dts
> create mode 100644 arch/arm/boot/dts/ep93xx-ts7250.dts
> create mode 100644 arch/arm/boot/dts/ep93xx.dtsi
>
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index 59829fc90315..a68f868fffe7 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -1670,3 +1670,4 @@ dtb-$(CONFIG_ARCH_ASPEED) += \
> aspeed-bmc-vegman-n110.dtb \
> aspeed-bmc-vegman-rx20.dtb \
> aspeed-bmc-vegman-sx20.dtb
> +dtb-$(CONFIG_ARCH_EP93XX) += ep93xx-ts7250.dtb
> diff --git a/arch/arm/boot/dts/ep93xx-bk3.dts b/arch/arm/boot/dts/ep93xx-bk3.dts
> new file mode 100644
> index 000000000000..215587c498e6
> --- /dev/null
> +++ b/arch/arm/boot/dts/ep93xx-bk3.dts
> @@ -0,0 +1,119 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Device Tree file for Liebherr controller BK3.1 based on Cirrus EP9302 SoC
> + */
> +/dts-v1/;
> +#include "ep93xx.dtsi"
> +
> +/ {
> + model = "Liebherr controller BK3.1";
> + compatible = "liebherr,bk3", "cirrus,ep9301";
> +
> + chosen {
> + };
> +
> + memory {
> + device_type = "memory";
> + };
> +
> + soc {
> + nand-controller@60000000 {
Override/extend by label/phandle.
> + compatible = "technologic,ts7200-nand";
> + reg = <0x60000000 0x8000000>;
> + #address-cells = <1>;
> + #size-cells = <1>;
> +
> + partitions {
> + compatible = "fixed-partitions";
> + #address-cells = <1>;
> + #size-cells = <1>;
> +
> + partition@0 {
> + label = "System";
> + reg = <0x00000000 0x01e00000>;
> + read-only;
> + };
> +
> + partition@1e00000 {
> + label = "Data";
> + reg = <0x01e00000 0x05f20000>;
> + };
> +
> + partition@7d20000 {
> + label = "RedBoot";
> + reg = <0x07d20000 0x002e0000>;
> + read-only;
> + };
> + };
> + };
> +
> + syscon: syscon@80930000 {
Override/extend by label/phandle.
> + pinctrl: pinctrl {
> + compatible = "cirrus,ep9301-pinctrl";
Why this is board specific?
> + };
> + };
> +
> + gpio1: gpio@80840004 {
Override/extend by label/phandle.
> + /* PWM */
> + gpio-ranges = <&pinctrl 6 163 1>;
> + };
> + };
> +};
> +
> +&gpio1 {
> + /* PWM */
> + gpio-ranges = <&pinctrl 6 163 1>;
> +};
> +
> +&gpio4 {
> + gpio-ranges = <&pinctrl 0 97 2>;
> + status = "okay";
> +};
> +
> +&gpio6 {
> + gpio-ranges = <&pinctrl 0 87 2>;
> + status = "okay";
> +};
> +
> +&gpio7 {
> + gpio-ranges = <&pinctrl 2 199 4>;
> + status = "okay";
> +};
> +
> +&i2c {
> + status = "okay";
> +};
> +
> +&spi0: spi@808a0000 {
> + cs-gpios = <&gpio5 3 0>;
Use proper defines for flags.
> + status = "okay";
What's here? Empty enabled bus?
> +};
> +
> +ð0 {
> + phy-handle = <&phy0>;
> +};
> +
> +&mdio0 {
> + phy0: ethernet-phy@1 {
> + reg = <1>;
> + device_type = "ethernet-phy";
> + };
> +};
> +
> +&uart0 {
> + status = "okay";
> +};
> +
> +&uart1 {
> + status = "okay";
> +};
> +
> +&usb {
> + status = "okay";
> +};
> +
> +&i2s {
Up to you, but I seriously recommend keeping all labels ordered by name.
Avoids conflicts.
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2s_on_ac97_pins>;
> + /delete-property/ status;
??? I don't understand. Why would you do this?
...
> diff --git a/arch/arm/boot/dts/ep93xx.dtsi b/arch/arm/boot/dts/ep93xx.dtsi
> new file mode 100644
> index 000000000000..6da556ceaf04
> --- /dev/null
> +++ b/arch/arm/boot/dts/ep93xx.dtsi
> @@ -0,0 +1,466 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Device Tree file for Cirrus Logic systems EP93XX SoC
> + */
> +#include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/leds/common.h>
> +#include <dt-bindings/input/input.h>
> +#include <dt-bindings/clock/cirrus,ep93xx-clock.h>
> +/ {
> + soc {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges;
> + compatible = "simple-bus";
> +
> + syscon: syscon@80930000 {
> + compatible = "cirrus,ep9301-syscon",
> + "syscon", "simple-mfd";
Broken wrapping. Align these with previous ".
> + reg = <0x80930000 0x1000>;
> +
> + ep9301-reboot {
Just "reboot" (and fix bindings)... but why would you need it in the
first place? I think something is seriously missing in your bindings.
> + compatible = "cirrus,ep9301-reboot";
> + };
> +
> + eclk: clock-controller {
> + #clock-cells = <1>;
> + compatible = "cirrus,ep9301-clk";
> + status = "okay";
> + clocks = <&xtali>;
> + };
> +
> + pinctrl: pinctrl {
Missing compatible.
> + spi_default_pins: pins-spi {
> + function = "spi";
> + groups = "ssp";
> + };
> +
> + ac97_default_pins: pins-ac97 {
> + function = "ac97";
> + groups = "ac97";
> + };
> +
> + i2s_on_ssp_pins: pins-i2sonssp {
> + function = "i2s";
> + groups = "i2s_on_ssp";
> + };
> +
> + i2s_on_ac97_pins: pins-i2sonac97 {
> + function = "i2s";
> + groups = "i2s_on_ac97";
> + };
> +
> + gpio1_default_pins: pins-gpio1 {
> + function = "gpio";
> + groups = "gpio1agrp";
> + };
> +
> + pwm1_default_pins: pins-pwm1 {
> + function = "pwm";
> + groups = "pwm1";
> + };
> +
> + gpio2_default_pins: pins-gpio2 {
> + function = "gpio";
> + groups = "gpio2agrp";
> + };
> +
> + gpio3_default_pins: pins-gpio3 {
> + function = "gpio";
> + groups = "gpio3agrp";
> + };
> +
> + keypad_default_pins: pins-keypad {
> + function = "keypad";
> + groups = "keypadgrp";
> + };
> +
> + gpio4_default_pins: pins-gpio4 {
> + function = "gpio";
> + groups = "gpio4agrp";
> + };
> +
> + gpio6_default_pins: pins-gpio6 {
> + function = "gpio";
> + groups = "gpio6agrp";
> + };
> +
> + gpio7_default_pins: pins-gpio7 {
> + function = "gpio";
> + groups = "gpio7agrp";
> + };
> +
> + ide_default_pins: pins-ide {
> + function = "pata";
> + groups = "idegrp";
> + };
> +
> + lcd_on_dram0_pins: pins-rasteronsdram0 {
> + function = "lcd";
> + groups = "rasteronsdram0grp";
> + };
> +
> + lcd_on_dram3_pins: pins-rasteronsdram3 {
> + function = "lcd";
> + groups = "rasteronsdram3grp";
I would expect somewhere two groups since you explicitly allow it.
> + };
> + };
> + };
> +
> + vic0: interrupt-controller@800b0000 {
> + compatible = "arm,pl192-vic";
> + interrupt-controller;
> + reg = <0x800b0000 0x1000>;
compatible first, reg is second. ranges if present - third. Fix it
everywhere.
> + #interrupt-cells = <1>;
> + valid-mask = <0x7ffffffc>;
> + valid-wakeup-mask = <0x0>;
> + };
> +
> + vic1: interrupt-controller@800c0000 {
> + compatible = "arm,pl192-vic";
> + interrupt-controller;
> + reg = <0x800c0000 0x1000>;
> + #interrupt-cells = <1>;
> + valid-mask = <0x1fffffff>;
> + valid-wakeup-mask = <0x0>;
> + };
> +
> + timer: timer@80810000 {
> + compatible = "cirrus,ep9301-timer";
> + reg = <0x80810000 0x100>;
> + interrupt-parent = <&vic1>;
> + interrupts = <19>;
> + };
> +
> + dma0: dma-controller@80000000 {
> + compatible = "cirrus,ep9301-dma-m2p";
> + reg = <0x80000000 0x0040>,
> + <0x80000040 0x0040>,
> + <0x80000080 0x0040>,
> + <0x800000c0 0x0040>,
> + <0x80000240 0x0040>,
> + <0x80000200 0x0040>,
> + <0x800002c0 0x0040>,
> + <0x80000280 0x0040>,
> + <0x80000340 0x0040>,
> + <0x80000300 0x0040>;
> + clocks = <&eclk EP93XX_CLK_M2P0>,
> + <&eclk EP93XX_CLK_M2P1>,
> + <&eclk EP93XX_CLK_M2P2>,
> + <&eclk EP93XX_CLK_M2P3>,
> + <&eclk EP93XX_CLK_M2P4>,
> + <&eclk EP93XX_CLK_M2P5>,
> + <&eclk EP93XX_CLK_M2P6>,
> + <&eclk EP93XX_CLK_M2P7>,
> + <&eclk EP93XX_CLK_M2P8>,
> + <&eclk EP93XX_CLK_M2P9>;
> + clock-names = "m2p0", "m2p1",
> + "m2p2", "m2p3",
> + "m2p4", "m2p5",
> + "m2p6", "m2p7",
> + "m2p8", "m2p9";
> + interrupt-parent = <&vic0>;
> + interrupts = <7>, <8>, <9>, <10>, <11>,
> + <12>, <13>, <14>, <15>, <16>;
> + #dma-cells = <1>;
> + };
> +
> + dma1: dma-controller@80000100 {
> + compatible = "cirrus,ep9301-dma-m2m";
> + reg = <0x80000100 0x0040>,
> + <0x80000140 0x0040>;
> + clocks = <&eclk EP93XX_CLK_M2M0>,
> + <&eclk EP93XX_CLK_M2M1>;
> + clock-names = "m2m0", "m2m1";
> + interrupt-parent = <&vic0>;
> + interrupts = <17>, <18>;
> + #dma-cells = <1>;
> + };
> +
> + i2s: i2s@80820000 {
> + compatible = "cirrus,ep9301-i2s";
> + #sound-dai-cells = <0>;
> + reg = <0x80820000 0x100>;
> + interrupt-parent = <&vic1>;
> + interrupts = <28>;
> + clocks = <&eclk EP93XX_CLK_I2S_MCLK
> + &eclk EP93XX_CLK_I2S_SCLK
> + &eclk EP93XX_CLK_I2S_LRCLK>;
> + clock-names = "mclk", "sclk", "lrclk";
> + status = "disabled";
> + };
> +
> + gpio0: gpio@80840000 {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x80840000 0x04>,
> + <0x80840010 0x04>,
> + <0x80840090 0x1c>;
Messed wrapping.
> + reg-names = "data", "dir", "intr";
> + gpio-controller;
> + #gpio-cells = <2>;
> + interrupt-controller;
> + interrupt-parent = <&vic1>;
> + interrupts = <27>;
> + };
> +
> + gpio1: gpio@80840004 {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x80840004 0x04>,
> + <0x80840014 0x04>,
> + <0x808400ac 0x1c>;
Ditto, in other places as well.
> + reg-names = "data", "dir", "intr";
> + gpio-controller;
> + #gpio-cells = <2>;
> + interrupt-controller;
> + interrupt-parent = <&vic1>;
> + interrupts = <27>;
> + };
> +
> + gpio2: gpio@80840008 {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x80840008 0x04>,
> + <0x80840018 0x04>;
> + reg-names = "data", "dir";
> + gpio-controller;
> + #gpio-cells = <2>;
> + status = "disabled";
Status is usually last.
> + pinctrl-names = "default";
> + pinctrl-0 = <&gpio2_default_pins>;
> + };
> +
> + gpio3: gpio@8084000c {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x8084000c 0x04>,
> + <0x8084001c 0x04>;
> + reg-names = "data", "dir";
> + gpio-controller;
> + #gpio-cells = <2>;
> + status = "disabled";
> + pinctrl-names = "default";
> + pinctrl-0 = <&gpio3_default_pins>;
> + };
> +
> + gpio4: gpio@80840020 {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x80840020 0x04>,
> + <0x80840024 0x04>;
> + reg-names = "data", "dir";
> + gpio-controller;
> + #gpio-cells = <2>;
> + status = "disabled";
> + pinctrl-names = "default";
> + pinctrl-0 = <&gpio4_default_pins>;
> + };
> +
> + gpio5: gpio@80840030 {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x80840030 0x04>,
> + <0x80840034 0x04>,
> + <0x8084004c 0x1c>;
> + reg-names = "data", "dir", "intr";
> + gpio-controller;
> + #gpio-cells = <2>;
> + interrupt-controller;
> + interrupts-extended = <&vic0 19>, <&vic0 20>,
> + <&vic0 21>, <&vic0 22>,
> + <&vic1 15>, <&vic1 16>,
> + <&vic1 17>, <&vic1 18>;
> + };
> +
> + gpio6: gpio@80840038 {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x80840038 0x04>,
> + <0x8084003c 0x04>;
> + reg-names = "data", "dir";
> + gpio-controller;
> + #gpio-cells = <2>;
> + status = "disabled";
> + pinctrl-names = "default";
> + pinctrl-0 = <&gpio6_default_pins>;
> + };
> +
> + gpio7: gpio@80840040 {
> + compatible = "cirrus,ep9301-gpio";
> + reg = <0x80840040 0x04>,
> + <0x80840044 0x04>;
> + reg-names = "data", "dir";
> + gpio-controller;
> + #gpio-cells = <2>;
> + status = "disabled";
> + pinctrl-names = "default";
> + pinctrl-0 = <&gpio7_default_pins>;
> + };
> +
> + ide: ide@800a0000 {
> + compatible = "cirrus,ep9312-pata";
> + reg = <0x800a0000 0x38>;
> + interrupt-parent = <&vic1>;
> + interrupts = <8>;
> + status = "disabled";
> + pinctrl-names = "default";
> + pinctrl-0 = <&ide_default_pins>;
> + };
> +
> + uart0: uart@808c0000 {
This should scream with dtbs_check. serial.
It does not look like you tested the DTS against bindings. Please run
`make dtbs_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).
> + compatible = "arm,primecell";
> + reg = <0x808c0000 0x1000>;
> + arm,primecell-periphid = <0x00041010>;
> + clocks = <&eclk EP93XX_CLK_UART1>, <&eclk EP93XX_CLK_UART>;
> + clock-names = "apb:uart1", "apb_pclk";
> + interrupt-parent = <&vic1>;
> + interrupts = <20>;
> + status = "disabled";
> + };
> +
> + uart1: uart@808d0000 {
> + compatible = "arm,primecell";
> + reg = <0x808d0000 0x1000>;
> + arm,primecell-periphid = <0x00041010>;
> + clocks = <&eclk EP93XX_CLK_UART2>, <&eclk EP93XX_CLK_UART>;
> + clock-names = "apb:uart2", "apb_pclk";
> + interrupt-parent = <&vic1>;
> + interrupts = <22>;
> + status = "disabled";
> + };
> +
> + uart2: uart@808b0000 {
> + compatible = "arm,primecell";
> + reg = <0x808b0000 0x1000>;
> + arm,primecell-periphid = <0x00041010>;
> + clocks = <&eclk EP93XX_CLK_UART3>, <&eclk EP93XX_CLK_UART>;
> + clock-names = "apb:uart3", "apb_pclk";
> + interrupt-parent = <&vic1>;
> + interrupts = <23>;
> + status = "disabled";
> + };
> +
> + usb0: usb@80020000 {
> + compatible = "generic-ohci";
> + reg = <0x80020000 0x10000>;
> + interrupt-parent = <&vic1>;
> + interrupts = <24>;
> + clocks = <&eclk EP93XX_CLK_USB>;
> + status = "disabled";
> + };
> +
> + eth0: ethernet@80010000 {
> + compatible = "cirrus,ep9301-eth";
> + reg = <0x80010000 0x10000>;
> + interrupt-parent = <&vic1>;
> + interrupts = <7>;
> + mdio0: mdio {
> + #address-cells = <1>;
> + #size-cells = <0>;
Your SoC comes with mdio? If so, why is this empty?
> + };
> + };
> +
> + rtc0: rtc@80920000 {
> + compatible = "cirrus,ep9301-rtc";
> + reg = <0x80920000 0x100>;
> + };
> +
> + spi0: spi@808a0000 {
> + compatible = "cirrus,ep9301-spi";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + reg = <0x808a0000 0x18>;
> + interrupt-parent = <&vic1>;
> + interrupts = <21>;
> + clocks = <&eclk EP93XX_CLK_SPI>;
> + cs-gpios = <&gpio5 2 0>;
defines... but why is it here in the first place? Rarely CS gpios are
part of the SoC. I have several of such questions further as well, so
this looks like you are mixing SoC and boards in one file.
> + cirrus,ep9301-use-dma;
> + pinctrl-names = "default";
> + pinctrl-0 = <&spi_default_pins>;
> + status = "disabled";
> + };
> +
> + adc: adc@80900000 {
> + compatible = "cirrus,ep9301-adc";
> + reg = <0x80900000 0x28>;
> + clocks = <&eclk EP93XX_CLK_ADC>;
> + interrupt-parent = <&vic0>;
> + interrupts = <30>;
> + status = "disabled";
> + };
> +
> + watchdog0: watchdog@80940000 {
> + compatible = "cirrus,ep9301-wdt";
> + reg = <0x80940000 0x08>;
> + };
> +
> + pwm0: pwm@80910000 {
> + compatible = "cirrus,ep9301-pwm";
> + reg = <0x80910000 0x10>;
> + clocks = <&eclk EP93XX_CLK_PWM>;
> + status = "disabled";
> + };
> +
> + pwm1: pwm@80910020 {
> + compatible = "cirrus,ep9301-pwm";
> + reg = <0x80910020 0x10>;
> + clocks = <&eclk EP93XX_CLK_PWM>;
> + status = "disabled";
> + pinctrl-names = "default";
> + pinctrl-0 = <&pwm1_default_pins>;
> + };
> +
> + keypad: keypad@800f0000 {
> + compatible = "cirrus,ep9307-keypad";
> + reg = <0x800f0000 0x0c>;
> + interrupt-parent = <&vic0>;
> + interrupts = <29>;
> + clocks = <&eclk EP93XX_CLK_KEYPAD>;
> + pinctrl-names = "default";
> + pinctrl-0 = <&keypad_default_pins>;
> + linux,keymap =
> + <KEY_UP>,
> + <KEY_DOWN>,
> + <KEY_VOLUMEDOWN>,
> + <KEY_HOME>,
> + <KEY_RIGHT>,
> + <KEY_LEFT>,
> + <KEY_ENTER>,
> + <KEY_VOLUMEUP>,
> + <KEY_F6>,
> + <KEY_F8>,
> + <KEY_F9>,
> + <KEY_F10>,
> + <KEY_F1>,
> + <KEY_F2>,
> + <KEY_F3>,
> + <KEY_POWER>;
> + };
> + };
> +
> + xtali: oscillator {
> + compatible = "fixed-clock";
> + #clock-cells = <0>;
> + clock-frequency = <14745600>;
> + clock-output-names = "xtali";
> + };
> +
> + i2c0: i2c0 {
i2c or i2c-0
> + compatible = "i2c-gpio";
> + sda-gpios = <&gpio6 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> + scl-gpios = <&gpio6 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
Wait, what? Why this is disabled? If this is part of the SoC, although
hardly looks like, then it should be complete. What is missing? How one
could design SoC with incomplete GPIO I2C controller?
> + };
> +
> + leds {
> + compatible = "gpio-leds";
I really doubt this is property of the SoC. Please double check as it
really looks wrong.
> + led0 {
led-0
> + label = "grled";
> + gpios = <&gpio4 0 GPIO_ACTIVE_HIGH>;
> + linux,default-trigger = "heartbeat";
> + function = LED_FUNCTION_HEARTBEAT;
> + };
> +
> + led1 {
led-1
> + label = "rdled";
> + gpios = <&gpio4 1 GPIO_ACTIVE_HIGH>;
> + function = LED_FUNCTION_FAULT;
> + };
> + };
> +};
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH v1 35/43] ARM: dts: add device tree for ep93xx Soc
2023-06-01 8:30 ` Krzysztof Kozlowski
@ 2023-07-05 16:06 ` Nikita Shubin
0 siblings, 0 replies; 20+ messages in thread
From: Nikita Shubin @ 2023-07-05 16:06 UTC (permalink / raw)
To: Krzysztof Kozlowski, Alexander Sverdlin, Arnd Bergmann,
Linus Walleij, Olof Johansson, soc, Rob Herring,
Krzysztof Kozlowski
Cc: Michael Peters, Kris Bahnsen, linux-arm-kernel, devicetree,
linux-kernel
Hello Krzysztof!
On Thu, 2023-06-01 at 10:30 +0200, Krzysztof Kozlowski wrote:
> On 01/06/2023 07:45, Nikita Shubin wrote:
> > This adds a divice for Cirrus ep93xx SoC amd ts7250 board that has
> > been
>
> device
>
> > my testing target for ep93xx device support.
> >
> > Also inluded device tree for Liebherr BK3.1 board through it's not
> > a
>
> included
>
> > complete support.
>
> Thank you for your patch. There is something to discuss/improve.
>
>
> >
> > Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
> > ---
> >
> > Notes:
> > v0 -> v1:
> >
> > - add empty chosen node
> > - s/dallas,rtc-m48t86/st,m48t86/
> > - changed phy_id to phy-handle
> > - dropped gpio chip-label's
> > - s/eth@80010000/ethernet@80010000
> > - s/use_dma/ep9301,use-dma
> > - added i2s to bk3
> >
> > arch/arm/boot/dts/Makefile | 1 +
> > arch/arm/boot/dts/ep93xx-bk3.dts | 119 +++++++
> > arch/arm/boot/dts/ep93xx-ts7250.dts | 132 ++++++++
> > arch/arm/boot/dts/ep93xx.dtsi | 466
> > ++++++++++++++++++++++++++++
>
> Split adding DTSI from adding boards.
>
> > 4 files changed, 718 insertions(+)
> > create mode 100644 arch/arm/boot/dts/ep93xx-bk3.dts
> > create mode 100644 arch/arm/boot/dts/ep93xx-ts7250.dts
> > create mode 100644 arch/arm/boot/dts/ep93xx.dtsi
> >
> > diff --git a/arch/arm/boot/dts/Makefile
> > b/arch/arm/boot/dts/Makefile
> > index 59829fc90315..a68f868fffe7 100644
> > --- a/arch/arm/boot/dts/Makefile
> > +++ b/arch/arm/boot/dts/Makefile
> > @@ -1670,3 +1670,4 @@ dtb-$(CONFIG_ARCH_ASPEED) += \
> > aspeed-bmc-vegman-n110.dtb \
> > aspeed-bmc-vegman-rx20.dtb \
> > aspeed-bmc-vegman-sx20.dtb
> > +dtb-$(CONFIG_ARCH_EP93XX) += ep93xx-ts7250.dtb
> > diff --git a/arch/arm/boot/dts/ep93xx-bk3.dts
> > b/arch/arm/boot/dts/ep93xx-bk3.dts
> > new file mode 100644
> > index 000000000000..215587c498e6
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/ep93xx-bk3.dts
> > @@ -0,0 +1,119 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Device Tree file for Liebherr controller BK3.1 based on Cirrus
> > EP9302 SoC
> > + */
> > +/dts-v1/;
> > +#include "ep93xx.dtsi"
> > +
> > +/ {
> > + model = "Liebherr controller BK3.1";
> > + compatible = "liebherr,bk3", "cirrus,ep9301";
> > +
> > + chosen {
> > + };
> > +
> > + memory {
> > + device_type = "memory";
> > + };
> > +
> > + soc {
> > + nand-controller@60000000 {
>
> Override/extend by label/phandle.
>
> > + compatible = "technologic,ts7200-nand";
> > + reg = <0x60000000 0x8000000>;
> > + #address-cells = <1>;
> > + #size-cells = <1>;
> > +
> > + partitions {
> > + compatible = "fixed-partitions";
> > + #address-cells = <1>;
> > + #size-cells = <1>;
> > +
> > + partition@0 {
> > + label = "System";
> > + reg = <0x00000000
> > 0x01e00000>;
> > + read-only;
> > + };
> > +
> > + partition@1e00000 {
> > + label = "Data";
> > + reg = <0x01e00000
> > 0x05f20000>;
> > + };
> > +
> > + partition@7d20000 {
> > + label = "RedBoot";
> > + reg = <0x07d20000
> > 0x002e0000>;
> > + read-only;
> > + };
> > + };
> > + };
> > +
> > + syscon: syscon@80930000 {
>
> Override/extend by label/phandle.
>
> > + pinctrl: pinctrl {
> > + compatible = "cirrus,ep9301-
> > pinctrl";
>
> Why this is board specific?
You are right - it's SoC specific, but currently we only have boards
with ep9302 with according device trees:
- ts7250
- bk3
- edb9302
We were hoping someone with other SoC's will join - like Hartley
Sweeten with Vision Engraving Systems EP9307 SoM, but no one showed up.
I've changed added compatible "cirrus,ep9301-pinctrl" in ep93xx.dtsi as
default and removed from all other board .dts.
>
> > + };
> > + };
> > +
> > + gpio1: gpio@80840004 {
>
> Override/extend by label/phandle.
>
> > + /* PWM */
> > + gpio-ranges = <&pinctrl 6 163 1>;
> > + };
> > + };
> > +};
> > +
> > +&gpio1 {
> > + /* PWM */
> > + gpio-ranges = <&pinctrl 6 163 1>;
> > +};
> > +
> > +&gpio4 {
> > + gpio-ranges = <&pinctrl 0 97 2>;
> > + status = "okay";
> > +};
> > +
> > +&gpio6 {
> > + gpio-ranges = <&pinctrl 0 87 2>;
> > + status = "okay";
> > +};
> > +
> > +&gpio7 {
> > + gpio-ranges = <&pinctrl 2 199 4>;
> > + status = "okay";
> > +};
> > +
> > +&i2c {
> > + status = "okay";
> > +};
> > +
> > +&spi0: spi@808a0000 {
> > + cs-gpios = <&gpio5 3 0>;
>
> Use proper defines for flags.
>
> > + status = "okay";
>
> What's here? Empty enabled bus?
>
>
> > +};
> > +
> > +ð0 {
> > + phy-handle = <&phy0>;
> > +};
> > +
> > +&mdio0 {
> > + phy0: ethernet-phy@1 {
> > + reg = <1>;
> > + device_type = "ethernet-phy";
> > + };
> > +};
> > +
> > +&uart0 {
> > + status = "okay";
> > +};
> > +
> > +&uart1 {
> > + status = "okay";
> > +};
> > +
> > +&usb {
> > + status = "okay";
> > +};
> > +
> > +&i2s {
>
> Up to you, but I seriously recommend keeping all labels ordered by
> name.
> Avoids conflicts.
>
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&i2s_on_ac97_pins>;
> > + /delete-property/ status;
>
> ??? I don't understand. Why would you do this?
>
> ...
>
> > diff --git a/arch/arm/boot/dts/ep93xx.dtsi
> > b/arch/arm/boot/dts/ep93xx.dtsi
> > new file mode 100644
> > index 000000000000..6da556ceaf04
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/ep93xx.dtsi
> > @@ -0,0 +1,466 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Device Tree file for Cirrus Logic systems EP93XX SoC
> > + */
> > +#include <dt-bindings/gpio/gpio.h>
> > +#include <dt-bindings/leds/common.h>
> > +#include <dt-bindings/input/input.h>
> > +#include <dt-bindings/clock/cirrus,ep93xx-clock.h>
> > +/ {
> > + soc {
> > + #address-cells = <1>;
> > + #size-cells = <1>;
> > + ranges;
> > + compatible = "simple-bus";
> > +
> > + syscon: syscon@80930000 {
> > + compatible = "cirrus,ep9301-syscon",
> > + "syscon", "simple-
> > mfd";
>
> Broken wrapping. Align these with previous ".
>
> > + reg = <0x80930000 0x1000>;
> > +
> > + ep9301-reboot {
>
> Just "reboot" (and fix bindings)... but why would you need it in the
> first place? I think something is seriously missing in your bindings.
>
> > + compatible = "cirrus,ep9301-
> > reboot";
> > + };
> > +
> > + eclk: clock-controller {
> > + #clock-cells = <1>;
> > + compatible = "cirrus,ep9301-clk";
> > + status = "okay";
> > + clocks = <&xtali>;
> > + };
> > +
> > + pinctrl: pinctrl {
>
> Missing compatible.
>
> > + spi_default_pins: pins-spi {
> > + function = "spi";
> > + groups = "ssp";
> > + };
> > +
> > + ac97_default_pins: pins-ac97 {
> > + function = "ac97";
> > + groups = "ac97";
> > + };
> > +
> > + i2s_on_ssp_pins: pins-i2sonssp {
> > + function = "i2s";
> > + groups = "i2s_on_ssp";
> > + };
> > +
> > + i2s_on_ac97_pins: pins-i2sonac97 {
> > + function = "i2s";
> > + groups = "i2s_on_ac97";
> > + };
> > +
> > + gpio1_default_pins: pins-gpio1 {
> > + function = "gpio";
> > + groups = "gpio1agrp";
> > + };
> > +
> > + pwm1_default_pins: pins-pwm1 {
> > + function = "pwm";
> > + groups = "pwm1";
> > + };
> > +
> > + gpio2_default_pins: pins-gpio2 {
> > + function = "gpio";
> > + groups = "gpio2agrp";
> > + };
> > +
> > + gpio3_default_pins: pins-gpio3 {
> > + function = "gpio";
> > + groups = "gpio3agrp";
> > + };
> > +
> > + keypad_default_pins: pins-keypad {
> > + function = "keypad";
> > + groups = "keypadgrp";
> > + };
> > +
> > + gpio4_default_pins: pins-gpio4 {
> > + function = "gpio";
> > + groups = "gpio4agrp";
> > + };
> > +
> > + gpio6_default_pins: pins-gpio6 {
> > + function = "gpio";
> > + groups = "gpio6agrp";
> > + };
> > +
> > + gpio7_default_pins: pins-gpio7 {
> > + function = "gpio";
> > + groups = "gpio7agrp";
> > + };
> > +
> > + ide_default_pins: pins-ide {
> > + function = "pata";
> > + groups = "idegrp";
> > + };
> > +
> > + lcd_on_dram0_pins: pins-
> > rasteronsdram0 {
> > + function = "lcd";
> > + groups =
> > "rasteronsdram0grp";
> > + };
> > +
> > + lcd_on_dram3_pins: pins-
> > rasteronsdram3 {
> > + function = "lcd";
> > + groups =
> > "rasteronsdram3grp";
>
> I would expect somewhere two groups since you explicitly allow it.
>
> > + };
> > + };
> > + };
> > +
> > + vic0: interrupt-controller@800b0000 {
> > + compatible = "arm,pl192-vic";
> > + interrupt-controller;
> > + reg = <0x800b0000 0x1000>;
>
> compatible first, reg is second. ranges if present - third. Fix it
> everywhere.
>
> > + #interrupt-cells = <1>;
> > + valid-mask = <0x7ffffffc>;
> > + valid-wakeup-mask = <0x0>;
> > + };
> > +
> > + vic1: interrupt-controller@800c0000 {
> > + compatible = "arm,pl192-vic";
> > + interrupt-controller;
> > + reg = <0x800c0000 0x1000>;
> > + #interrupt-cells = <1>;
> > + valid-mask = <0x1fffffff>;
> > + valid-wakeup-mask = <0x0>;
> > + };
> > +
> > + timer: timer@80810000 {
> > + compatible = "cirrus,ep9301-timer";
> > + reg = <0x80810000 0x100>;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <19>;
> > + };
> > +
> > + dma0: dma-controller@80000000 {
> > + compatible = "cirrus,ep9301-dma-m2p";
> > + reg = <0x80000000 0x0040>,
> > + <0x80000040 0x0040>,
> > + <0x80000080 0x0040>,
> > + <0x800000c0 0x0040>,
> > + <0x80000240 0x0040>,
> > + <0x80000200 0x0040>,
> > + <0x800002c0 0x0040>,
> > + <0x80000280 0x0040>,
> > + <0x80000340 0x0040>,
> > + <0x80000300 0x0040>;
> > + clocks = <&eclk EP93XX_CLK_M2P0>,
> > + <&eclk EP93XX_CLK_M2P1>,
> > + <&eclk EP93XX_CLK_M2P2>,
> > + <&eclk EP93XX_CLK_M2P3>,
> > + <&eclk EP93XX_CLK_M2P4>,
> > + <&eclk EP93XX_CLK_M2P5>,
> > + <&eclk EP93XX_CLK_M2P6>,
> > + <&eclk EP93XX_CLK_M2P7>,
> > + <&eclk EP93XX_CLK_M2P8>,
> > + <&eclk EP93XX_CLK_M2P9>;
> > + clock-names = "m2p0", "m2p1",
> > + "m2p2", "m2p3",
> > + "m2p4", "m2p5",
> > + "m2p6", "m2p7",
> > + "m2p8", "m2p9";
> > + interrupt-parent = <&vic0>;
> > + interrupts = <7>, <8>, <9>, <10>, <11>,
> > + <12>, <13>, <14>, <15>, <16>;
> > + #dma-cells = <1>;
> > + };
> > +
> > + dma1: dma-controller@80000100 {
> > + compatible = "cirrus,ep9301-dma-m2m";
> > + reg = <0x80000100 0x0040>,
> > + <0x80000140 0x0040>;
> > + clocks = <&eclk EP93XX_CLK_M2M0>,
> > + <&eclk EP93XX_CLK_M2M1>;
> > + clock-names = "m2m0", "m2m1";
> > + interrupt-parent = <&vic0>;
> > + interrupts = <17>, <18>;
> > + #dma-cells = <1>;
> > + };
> > +
> > + i2s: i2s@80820000 {
> > + compatible = "cirrus,ep9301-i2s";
> > + #sound-dai-cells = <0>;
> > + reg = <0x80820000 0x100>;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <28>;
> > + clocks = <&eclk EP93XX_CLK_I2S_MCLK
> > + &eclk EP93XX_CLK_I2S_SCLK
> > + &eclk EP93XX_CLK_I2S_LRCLK>;
> > + clock-names = "mclk", "sclk", "lrclk";
> > + status = "disabled";
> > + };
> > +
> > + gpio0: gpio@80840000 {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x80840000 0x04>,
> > + <0x80840010 0x04>,
> > + <0x80840090 0x1c>;
>
> Messed wrapping.
>
> > + reg-names = "data", "dir", "intr";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + interrupt-controller;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <27>;
> > + };
> > +
> > + gpio1: gpio@80840004 {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x80840004 0x04>,
> > + <0x80840014 0x04>,
> > + <0x808400ac 0x1c>;
>
> Ditto, in other places as well.
>
> > + reg-names = "data", "dir", "intr";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + interrupt-controller;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <27>;
> > + };
> > +
> > + gpio2: gpio@80840008 {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x80840008 0x04>,
> > + <0x80840018 0x04>;
> > + reg-names = "data", "dir";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + status = "disabled";
>
> Status is usually last.
>
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&gpio2_default_pins>;
> > + };
> > +
> > + gpio3: gpio@8084000c {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x8084000c 0x04>,
> > + <0x8084001c 0x04>;
> > + reg-names = "data", "dir";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + status = "disabled";
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&gpio3_default_pins>;
> > + };
> > +
> > + gpio4: gpio@80840020 {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x80840020 0x04>,
> > + <0x80840024 0x04>;
> > + reg-names = "data", "dir";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + status = "disabled";
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&gpio4_default_pins>;
> > + };
> > +
> > + gpio5: gpio@80840030 {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x80840030 0x04>,
> > + <0x80840034 0x04>,
> > + <0x8084004c 0x1c>;
> > + reg-names = "data", "dir", "intr";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + interrupt-controller;
> > + interrupts-extended = <&vic0 19>, <&vic0
> > 20>,
> > + <&vic0 21>, <&vic0 22>,
> > + <&vic1 15>, <&vic1 16>,
> > + <&vic1 17>, <&vic1 18>;
> > + };
> > +
> > + gpio6: gpio@80840038 {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x80840038 0x04>,
> > + <0x8084003c 0x04>;
> > + reg-names = "data", "dir";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + status = "disabled";
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&gpio6_default_pins>;
> > + };
> > +
> > + gpio7: gpio@80840040 {
> > + compatible = "cirrus,ep9301-gpio";
> > + reg = <0x80840040 0x04>,
> > + <0x80840044 0x04>;
> > + reg-names = "data", "dir";
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + status = "disabled";
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&gpio7_default_pins>;
> > + };
> > +
> > + ide: ide@800a0000 {
> > + compatible = "cirrus,ep9312-pata";
> > + reg = <0x800a0000 0x38>;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <8>;
> > + status = "disabled";
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&ide_default_pins>;
> > + };
> > +
> > + uart0: uart@808c0000 {
>
> This should scream with dtbs_check. serial.
>
> It does not look like you tested the DTS against bindings. Please run
> `make dtbs_check` (see
> Documentation/devicetree/bindings/writing-schema.rst for
> instructions).
make dtbs_check is totally clean now:
```
make -j34 -C build-linux ARCH=arm CROSS_COMPILE=armv4t-softfloat-linux-
gnueabi- dtbs_check
make[1]: Entering directory '/home/maquefel/workshop/ts7250-boot-
build/build-linux'
UPD include/config/kernel.release
DTC_CHK arch/arm/boot/dts/cirrus/ep93xx-edb9302.dtb
arch/arm/boot/dts/cirrus/ep93xx-edb9302.dtb:0:0: /soc/ac97@80880000:
failed to match any schema with compatible: ['cirrus,ep9301-ac97']
arch/arm/boot/dts/cirrus/ep93xx-edb9302.dtb:0:0:
/soc/spi@808a0000/codec@0: failed to match any schema with compatible:
['cirrus,cs4271']
/home/maquefel/workshop/ts7250-boot-build/build-
linux/arch/arm/boot/dts/cirrus/ep93xx-edb9302.dtb: sound: 'simple-
audio-card,convert-sample-format' does not match any of the regexes:
'^simple-audio-card,codec(@[0-9a-f]+)?$', '^simple-audio-card,cpu(@[0-
9a-f]+)?$', '^simple-audio-card,dai-link(@[0-9a-f]+)?$', '^simple-
audio-card,plat(@[0-9a-f]+)?$', 'pinctrl-[0-9]+'
From schema: /home/maquefel/workshop/ts7250-boot-
build/linux/Documentation/devicetree/bindings/sound/simple-card.yaml
make[1]: Leaving directory '/home/maquefel/workshop/ts7250-boot-
build/build-linux'
```
>
> > + compatible = "arm,primecell";
> > + reg = <0x808c0000 0x1000>;
> > + arm,primecell-periphid = <0x00041010>;
> > + clocks = <&eclk EP93XX_CLK_UART1>, <&eclk
> > EP93XX_CLK_UART>;
> > + clock-names = "apb:uart1", "apb_pclk";
> > + interrupt-parent = <&vic1>;
> > + interrupts = <20>;
> > + status = "disabled";
> > + };
> > +
> > + uart1: uart@808d0000 {
> > + compatible = "arm,primecell";
> > + reg = <0x808d0000 0x1000>;
> > + arm,primecell-periphid = <0x00041010>;
> > + clocks = <&eclk EP93XX_CLK_UART2>, <&eclk
> > EP93XX_CLK_UART>;
> > + clock-names = "apb:uart2", "apb_pclk";
> > + interrupt-parent = <&vic1>;
> > + interrupts = <22>;
> > + status = "disabled";
> > + };
> > +
> > + uart2: uart@808b0000 {
> > + compatible = "arm,primecell";
> > + reg = <0x808b0000 0x1000>;
> > + arm,primecell-periphid = <0x00041010>;
> > + clocks = <&eclk EP93XX_CLK_UART3>, <&eclk
> > EP93XX_CLK_UART>;
> > + clock-names = "apb:uart3", "apb_pclk";
> > + interrupt-parent = <&vic1>;
> > + interrupts = <23>;
> > + status = "disabled";
> > + };
> > +
> > + usb0: usb@80020000 {
> > + compatible = "generic-ohci";
> > + reg = <0x80020000 0x10000>;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <24>;
> > + clocks = <&eclk EP93XX_CLK_USB>;
> > + status = "disabled";
> > + };
> > +
> > + eth0: ethernet@80010000 {
> > + compatible = "cirrus,ep9301-eth";
> > + reg = <0x80010000 0x10000>;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <7>;
> > + mdio0: mdio {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
>
> Your SoC comes with mdio? If so, why is this empty?
It has a builtin MDIO and only reason for this is to provide phy-id via
device tree in a correct way:
```
ð0 {
phy-handle = <&phy0>;
};
&mdio0 {
phy0: ethernet-phy@1 {
reg = <1>;
device_type = "ethernet-phy";
};
};
```
There is no other purpose for this node.
Thank you Krzysztof!
All other issues fixed.
>
> > + };
> > + };
> > +
> > + rtc0: rtc@80920000 {
> > + compatible = "cirrus,ep9301-rtc";
> > + reg = <0x80920000 0x100>;
> > + };
> > +
> > + spi0: spi@808a0000 {
> > + compatible = "cirrus,ep9301-spi";
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > + reg = <0x808a0000 0x18>;
> > + interrupt-parent = <&vic1>;
> > + interrupts = <21>;
> > + clocks = <&eclk EP93XX_CLK_SPI>;
> > + cs-gpios = <&gpio5 2 0>;
>
> defines... but why is it here in the first place? Rarely CS gpios are
> part of the SoC. I have several of such questions further as well, so
> this looks like you are mixing SoC and boards in one file.
>
> > + cirrus,ep9301-use-dma;
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&spi_default_pins>;
> > + status = "disabled";
> > + };
> > +
> > + adc: adc@80900000 {
> > + compatible = "cirrus,ep9301-adc";
> > + reg = <0x80900000 0x28>;
> > + clocks = <&eclk EP93XX_CLK_ADC>;
> > + interrupt-parent = <&vic0>;
> > + interrupts = <30>;
> > + status = "disabled";
> > + };
> > +
> > + watchdog0: watchdog@80940000 {
> > + compatible = "cirrus,ep9301-wdt";
> > + reg = <0x80940000 0x08>;
> > + };
> > +
> > + pwm0: pwm@80910000 {
> > + compatible = "cirrus,ep9301-pwm";
> > + reg = <0x80910000 0x10>;
> > + clocks = <&eclk EP93XX_CLK_PWM>;
> > + status = "disabled";
> > + };
> > +
> > + pwm1: pwm@80910020 {
> > + compatible = "cirrus,ep9301-pwm";
> > + reg = <0x80910020 0x10>;
> > + clocks = <&eclk EP93XX_CLK_PWM>;
> > + status = "disabled";
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&pwm1_default_pins>;
> > + };
> > +
> > + keypad: keypad@800f0000 {
> > + compatible = "cirrus,ep9307-keypad";
> > + reg = <0x800f0000 0x0c>;
> > + interrupt-parent = <&vic0>;
> > + interrupts = <29>;
> > + clocks = <&eclk EP93XX_CLK_KEYPAD>;
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&keypad_default_pins>;
> > + linux,keymap =
> > + <KEY_UP>,
> > + <KEY_DOWN>,
> > + <KEY_VOLUMEDOWN>,
> > + <KEY_HOME>,
> > + <KEY_RIGHT>,
> > + <KEY_LEFT>,
> > + <KEY_ENTER>,
> > + <KEY_VOLUMEUP>,
> > + <KEY_F6>,
> > + <KEY_F8>,
> > + <KEY_F9>,
> > + <KEY_F10>,
> > + <KEY_F1>,
> > + <KEY_F2>,
> > + <KEY_F3>,
> > + <KEY_POWER>;
> > + };
> > + };
> > +
> > + xtali: oscillator {
> > + compatible = "fixed-clock";
> > + #clock-cells = <0>;
> > + clock-frequency = <14745600>;
> > + clock-output-names = "xtali";
> > + };
> > +
> > + i2c0: i2c0 {
>
> i2c or i2c-0
>
> > + compatible = "i2c-gpio";
> > + sda-gpios = <&gpio6 1
> > (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> > + scl-gpios = <&gpio6 0
> > (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > + status = "disabled";
>
> Wait, what? Why this is disabled? If this is part of the SoC,
> although
> hardly looks like, then it should be complete. What is missing? How
> one
> could design SoC with incomplete GPIO I2C controller?
>
> > + };
> > +
> > + leds {
> > + compatible = "gpio-leds";
>
> I really doubt this is property of the SoC. Please double check as it
> really looks wrong.
>
>
> > + led0 {
>
> led-0
>
> > + label = "grled";
> > + gpios = <&gpio4 0 GPIO_ACTIVE_HIGH>;
> > + linux,default-trigger = "heartbeat";
> > + function = LED_FUNCTION_HEARTBEAT;
> > + };
> > +
> > + led1 {
> led-1
>
> > + label = "rdled";
> > + gpios = <&gpio4 1 GPIO_ACTIVE_HIGH>;
> > + function = LED_FUNCTION_FAULT;
> > + };
> > + };
> > +};
>
> Best regards,
> Krzysztof
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v1 36/43] ARM: ep93xx: DT for the Cirrus ep93xx SoC platforms
[not found] <20230424123522.18302-1-nikita.shubin@maquefel.me>
` (6 preceding siblings ...)
2023-06-01 5:45 ` [PATCH v1 35/43] ARM: dts: add device tree for ep93xx Soc Nikita Shubin
@ 2023-06-01 5:45 ` Nikita Shubin
7 siblings, 0 replies; 20+ messages in thread
From: Nikita Shubin @ 2023-06-01 5:45 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Linus Walleij, Russell King,
Hartley Sweeten, Russell King (Oracle), Nathan Chancellor,
Nick Desaulniers, Masahiro Yamada, Nicolas Saenz Julienne
Cc: Nikita Shubin, Michael Peters, Kris Bahnsen, linux-arm-kernel,
linux-kernel
This adds compulsory device tree support to the Cirrus ep93xx ARMv4
platform.
- We select PINCTRL_EP93xx
- We select COMMON_CLK_EP93XX, as clock driver moved out of platform
code
- We select ARCH_HAS_RESET_CONTROLLER
And also we need ARM_ATAG_DTB_COMPAT to update device tree with
information about memory passed from bootloader.
We have to leave all MACH options as they are used for board checking
before decomp, to turn off watchdog and ethernet DMA.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
arch/arm/Makefile | 1 -
arch/arm/mach-ep93xx/Kconfig | 20 ++++++++++----------
arch/arm/mach-ep93xx/Makefile | 11 -----------
3 files changed, 10 insertions(+), 22 deletions(-)
delete mode 100644 arch/arm/mach-ep93xx/Makefile
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 547e5856eaa0..0e3d637cae6c 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -179,7 +179,6 @@ machine-$(CONFIG_ARCH_CLPS711X) += clps711x
machine-$(CONFIG_ARCH_DAVINCI) += davinci
machine-$(CONFIG_ARCH_DIGICOLOR) += digicolor
machine-$(CONFIG_ARCH_DOVE) += dove
-machine-$(CONFIG_ARCH_EP93XX) += ep93xx
machine-$(CONFIG_ARCH_EXYNOS) += exynos
machine-$(CONFIG_ARCH_FOOTBRIDGE) += footbridge
machine-$(CONFIG_ARCH_GEMINI) += gemini
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
index 703f3d232a60..812b71dcf60e 100644
--- a/arch/arm/mach-ep93xx/Kconfig
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -3,27 +3,27 @@ menuconfig ARCH_EP93XX
bool "EP93xx-based"
depends on ATAGS
depends on ARCH_MULTI_V4T
+ # CONFIG_ARCH_MULTI_V7 is not set
depends on CPU_LITTLE_ENDIAN
+ select ARCH_HAS_RESET_CONTROLLER
select ARCH_SPARSEMEM_ENABLE
select ARM_AMBA
select ARM_VIC
+ select ARM_APPENDED_DTB # Old Redboot bootloaders deployed
+ select ARM_ATAG_DTB_COMPAT # we need this to update dt memory node
+ select COMMON_CLK_EP93XX
+ select EP93XX_TIMER
select CLKSRC_MMIO
select CPU_ARM920T
select GPIOLIB
+ select PINCTRL
+ select PINCTRL_EP93XX
help
This enables support for the Cirrus EP93xx series of CPUs.
if ARCH_EP93XX
-menu "Cirrus EP93xx Implementation Options"
-
-config EP93XX_SOC_COMMON
- bool
- default y
- select SOC_BUS
- select LEDS_GPIO_REGISTER
-
-comment "EP93xx Platforms"
+# menu "EP93xx Platforms"
config MACH_BK3
bool "Support Liebherr BK3.1"
@@ -103,6 +103,6 @@ config MACH_VISION_EP9307
Say 'Y' here if you want your kernel to support the
Vision Engraving Systems EP9307 SoM.
-endmenu
+# endmenu
endif
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
deleted file mode 100644
index 62e37403df14..000000000000
--- a/arch/arm/mach-ep93xx/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for the linux kernel.
-#
-obj-y := core.o clock.o timer-ep93xx.o
-
-obj-$(CONFIG_EP93XX_DMA) += dma.o
-
-obj-$(CONFIG_MACH_EDB93XX) += edb93xx.o
-obj-$(CONFIG_MACH_TS72XX) += ts72xx.o
-obj-$(CONFIG_MACH_VISION_EP9307)+= vision_ep9307.o
--
2.37.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 20+ messages in thread