From: jsg Date: Fri, 12 Aug 2016 03:22:41 +0000 (+0000) Subject: Switch omap to the generic ofw pinctrl framework. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=16f6b372a0919c37d7c6eb1a23d2514864b85919;p=openbsd Switch omap to the generic ofw pinctrl framework. ok kettenis@ --- diff --git a/sys/arch/armv7/omap/if_cpsw.c b/sys/arch/armv7/omap/if_cpsw.c index 38f8a3374aa..b120b28c087 100644 --- a/sys/arch/armv7/omap/if_cpsw.c +++ b/sys/arch/armv7/omap/if_cpsw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cpsw.c,v 1.39 2016/08/06 10:07:45 jsg Exp $ */ +/* $OpenBSD: if_cpsw.c,v 1.40 2016/08/12 03:22:41 jsg Exp $ */ /* $NetBSD: if_cpsw.c,v 1.3 2013/04/17 14:36:34 bouyer Exp $ */ /* @@ -84,9 +84,9 @@ #include #include -#include #include +#include #include #define CPSW_TXFRAGS 16 @@ -351,7 +351,7 @@ cpsw_attach(struct device *parent, struct device *self, void *aux) */ memsize = 0x4000; - sitara_cm_pinctrlbyname(faa->fa_node, "default"); + pinctrl_byname(faa->fa_node, "default"); for (node = OF_child(faa->fa_node); node; node = OF_peer(node)) { memset(name, 0, sizeof(name)); @@ -361,7 +361,7 @@ cpsw_attach(struct device *parent, struct device *self, void *aux) if (strcmp(name, "ti,davinci_mdio") != 0) continue; - sitara_cm_pinctrlbyname(node, "default"); + pinctrl_byname(node, "default"); } timeout_set(&sc->sc_tick, cpsw_tick, sc); diff --git a/sys/arch/armv7/omap/omap_com.c b/sys/arch/armv7/omap/omap_com.c index 610c6097134..4b80887e737 100644 --- a/sys/arch/armv7/omap/omap_com.c +++ b/sys/arch/armv7/omap/omap_com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap_com.c,v 1.9 2016/08/06 10:07:45 jsg Exp $ */ +/* $OpenBSD: omap_com.c,v 1.10 2016/08/12 03:22:41 jsg Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. * All rights reserved. @@ -51,10 +51,10 @@ #include #include -#include #include #include +#include #define com_isr 8 #define ISR_RECV (ISR_RXPL | ISR_XMODE | ISR_RCVEIR) @@ -117,7 +117,7 @@ omapuart_attach(struct device *parent, struct device *self, void *aux) return; } - sitara_cm_pinctrlbyname(faa->fa_node, "default"); + pinctrl_byname(faa->fa_node, "default"); com_attach_subr(sc); diff --git a/sys/arch/armv7/omap/omgpio.c b/sys/arch/armv7/omap/omgpio.c index a4a80323c77..02dfbe8dd16 100644 --- a/sys/arch/armv7/omap/omgpio.c +++ b/sys/arch/armv7/omap/omgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omgpio.c,v 1.9 2016/08/11 04:33:06 jsg Exp $ */ +/* $OpenBSD: omgpio.c,v 1.10 2016/08/12 03:22:41 jsg Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn * @@ -33,7 +33,6 @@ #include #include -#include #include #include diff --git a/sys/arch/armv7/omap/ommmc.c b/sys/arch/armv7/omap/ommmc.c index 05f9647adc1..0ece1e3e15d 100644 --- a/sys/arch/armv7/omap/ommmc.c +++ b/sys/arch/armv7/omap/ommmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ommmc.c,v 1.28 2016/08/06 10:07:45 jsg Exp $ */ +/* $OpenBSD: ommmc.c,v 1.29 2016/08/12 03:22:41 jsg Exp $ */ /* * Copyright (c) 2009 Dale Rahn @@ -34,9 +34,9 @@ #include #include -#include #include +#include #include /* @@ -331,7 +331,7 @@ ommmc_attach(struct device *parent, struct device *self, void *aux) printf("\n"); - sitara_cm_pinctrlbyname(faa->fa_node, "default"); + pinctrl_byname(faa->fa_node, "default"); /* Enable ICLKEN, FCLKEN? */ prcm_enablemodule(PRCM_MMC0 + unit); diff --git a/sys/arch/armv7/omap/sitara_cm.c b/sys/arch/armv7/omap/sitara_cm.c index 4cb69dbba5b..112053a6a8d 100644 --- a/sys/arch/armv7/omap/sitara_cm.c +++ b/sys/arch/armv7/omap/sitara_cm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sitara_cm.c,v 1.3 2016/07/17 02:45:05 jsg Exp $ */ +/* $OpenBSD: sitara_cm.c,v 1.4 2016/08/12 03:22:41 jsg Exp $ */ /* $NetBSD: sitara_cm.c,v 1.1 2013/04/17 14:31:02 bouyer Exp $ */ /* * Copyright (c) 2010 @@ -63,9 +63,10 @@ #include #include +#include void sitara_cm_attach(struct device *parent, struct device *self, void *aux); -int sitara_cm_pinctrl(uint32_t); +int sitara_cm_pinctrl(uint32_t, void *); struct sitara_cm_softc { struct device sc_dev; @@ -379,6 +380,7 @@ sitara_cm_attach(struct device *parent, struct device *self, void *aux) struct sitara_cm_softc *sc = (struct sitara_cm_softc *)self; struct armv7_attach_args *aa = aux; uint32_t rev; + int node; if (sitara_cm_sc) panic("sitara_cm_attach: already attached"); @@ -389,6 +391,10 @@ sitara_cm_attach(struct device *parent, struct device *self, void *aux) aa->aa_dev->mem[0].size, 0, &sc->sc_ioh) != 0) panic("%s: bus_space_map failed!\n", __func__); + node = OF_finddevice("/ocp/l4_wkup@44c00000/scm@210000/pinmux@800"); + if (node != -1) + pinctrl_register(node, sitara_cm_pinctrl, sc); + sitara_cm_sc = sc; if (sitara_cm_reg_read_4(OMAP2SCM_REVISION, &rev) != 0) @@ -398,64 +404,9 @@ sitara_cm_attach(struct device *parent, struct device *self, void *aux) } int -sitara_cm_pinctrlbyid(int node, int id) -{ - char pinctrl[32]; - uint32_t *phandles; - int len, i; - - if (!sitara_cm_sc) - return -1; - - snprintf(pinctrl, sizeof(pinctrl), "pinctrl-%d", id); - len = OF_getproplen(node, pinctrl); - if (len <= 0) - return -1; - - phandles = malloc(len, M_TEMP, M_WAITOK); - OF_getpropintarray(node, pinctrl, phandles, len); - for (i = 0; i < len / sizeof(uint32_t); i++) - sitara_cm_pinctrl(phandles[i]); - free(phandles, M_TEMP, len); - return 0; -} - -int -sitara_cm_pinctrlbyname(int node, const char *config) -{ - char *names; - char *name; - char *end; - int id = 0; - int len; - - if (!sitara_cm_sc) - return -1; - - len = OF_getproplen(node, "pinctrl-names"); - if (len <= 0) - printf("no pinctrl-names\n"); - - names = malloc(len, M_TEMP, M_WAITOK); - OF_getprop(node, "pinctrl-names", names, len); - end = names + len; - name = names; - while (name < end) { - if (strcmp(name, config) == 0) { - free(names, M_TEMP, len); - return sitara_cm_pinctrlbyid(node, id); - } - name += strlen(name) + 1; - id++; - } - free(names, M_TEMP, len); - return -1; -} - -int -sitara_cm_pinctrl(uint32_t phandle) +sitara_cm_pinctrl(uint32_t phandle, void *cookie) { - struct sitara_cm_softc *sc = sitara_cm_sc; + struct sitara_cm_softc *sc = cookie; uint32_t *pins; int npins; int node; diff --git a/sys/arch/armv7/omap/sitara_cm.h b/sys/arch/armv7/omap/sitara_cm.h index 68158b2e57d..cbe85df0894 100644 --- a/sys/arch/armv7/omap/sitara_cm.h +++ b/sys/arch/armv7/omap/sitara_cm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sitara_cm.h,v 1.2 2016/07/17 02:45:05 jsg Exp $ */ +/* $OpenBSD: sitara_cm.h,v 1.3 2016/08/12 03:22:41 jsg Exp $ */ /* $NetBSD: sitara_cm.h,v 1.1 2013/04/17 14:31:02 bouyer Exp $ */ /* * Copyright (c) 2010 @@ -74,7 +74,5 @@ int sitara_cm_padconf_set_gpioflags(uint32_t gpio, uint32_t flags); void sitara_cm_padconf_get_gpioflags(uint32_t gpio, uint32_t *flags); int sitara_cm_reg_read_4(uint32_t reg, uint32_t *val); int sitara_cm_reg_write_4(uint32_t reg, uint32_t val); -int sitara_cm_pinctrlbyid(int node, int id); -int sitara_cm_pinctrlbyname(int node, const char *); #endif /* _OMAP_SCM_H_ */ diff --git a/sys/arch/armv7/omap/ti_iic.c b/sys/arch/armv7/omap/ti_iic.c index c50bee2665d..d454a8cdb9c 100644 --- a/sys/arch/armv7/omap/ti_iic.c +++ b/sys/arch/armv7/omap/ti_iic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ti_iic.c,v 1.8 2016/08/06 10:07:45 jsg Exp $ */ +/* $OpenBSD: ti_iic.c,v 1.9 2016/08/12 03:22:41 jsg Exp $ */ /* $NetBSD: ti_iic.c,v 1.4 2013/04/25 13:04:27 rkujawa Exp $ */ /* @@ -66,9 +66,9 @@ #include #include #include -#include #include +#include #include #ifndef AM335X_I2C_SLAVE_ADDR @@ -190,7 +190,7 @@ ti_iic_attach(struct device *parent, struct device *self, void *aux) faa->fa_reg[0].size, 0, &sc->sc_ioh)) panic("%s: bus_space_map failed!", DEVNAME(sc)); - sitara_cm_pinctrlbyname(faa->fa_node, "default"); + pinctrl_byname(faa->fa_node, "default"); sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_NET, ti_iic_intr, sc, DEVNAME(sc));