pinctrl-single,pins to handle mux settings and pad configuration.
The fdt data has offsets from the start of the pinmux address range so
the am335x specific pinmux offset from the scm base is added to the
offsets. This as not a new driver as sitaracm does manual table
driven pad configuration for gpio. If all the offsets in the
ti_padconf_devmap table were reduced by the am335x pinmux offset (0x800)
it may make sense to map only the pinmux memory region and not the
scm superset.
looks good kettenis@
-/* $OpenBSD: if_cpsw.c,v 1.36 2016/07/09 04:25:44 jsg Exp $ */
+/* $OpenBSD: if_cpsw.c,v 1.37 2016/07/17 02:45:05 jsg Exp $ */
/* $NetBSD: if_cpsw.c,v 1.3 2013/04/17 14:36:34 bouyer Exp $ */
/*
#include <arch/armv7/armv7/armv7var.h>
#include <arch/armv7/omap/if_cpswreg.h>
+#include <arch/armv7/omap/sitara_cm.h>
#include <dev/ofw/openfirm.h>
struct ifnet * const ifp = &ac->ac_if;
u_int32_t idver;
int error;
+ int node;
u_int i;
uint32_t intr[4];
uint32_t memsize;
+ char name[32];
if (faa->fa_nreg < 2 || (faa->fa_nintr != 4 && faa->fa_nintr != 12))
return;
*/
memsize = 0x4000;
+ sitara_cm_pinctrlbyname(faa->fa_node, "default");
+
+ for (node = OF_child(faa->fa_node); node; node = OF_peer(node)) {
+ memset(name, 0, sizeof(name));
+
+ if (OF_getprop(node, "compatible", name, sizeof(name)) == -1)
+ continue;
+
+ if (strcmp(name, "ti,davinci_mdio") != 0)
+ continue;
+ sitara_cm_pinctrlbyname(node, "default");
+ }
+
timeout_set(&sc->sc_tick, cpsw_tick, sc);
cpsw_get_port_config(sc->sc_port_config, faa->fa_node);
-/* $OpenBSD: omap_com.c,v 1.5 2016/06/19 14:38:13 jsg Exp $ */
+/* $OpenBSD: omap_com.c,v 1.6 2016/07/17 02:45:05 jsg Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
* All rights reserved.
#include <armv7/armv7/armv7var.h>
#include <armv7/armv7/armv7_machdep.h>
+#include <armv7/omap/sitara_cm.h>
#include <dev/ofw/fdt.h>
#include <dev/ofw/openfirm.h>
return;
}
+ sitara_cm_pinctrlbyname(faa->fa_node, "default");
+
com_attach_subr(sc);
(void)arm_intr_establish(irq, IPL_TTY, comintr,
-/* $OpenBSD: ommmc.c,v 1.25 2016/07/15 22:28:25 tom Exp $ */
+/* $OpenBSD: ommmc.c,v 1.26 2016/07/17 02:45:05 jsg Exp $ */
/*
* Copyright (c) 2009 Dale Rahn <drahn@openbsd.org>
#include <armv7/armv7/armv7var.h>
#include <armv7/omap/prcmvar.h>
+#include <armv7/omap/sitara_cm.h>
#include <dev/ofw/openfirm.h>
printf("\n");
+ sitara_cm_pinctrlbyname(faa->fa_node, "default");
+
/* Enable ICLKEN, FCLKEN? */
prcm_enablemodule(PRCM_MMC0 + unit);
-/* $OpenBSD: sitara_cm.c,v 1.2 2013/11/06 19:03:07 syl Exp $ */
+/* $OpenBSD: sitara_cm.c,v 1.3 2016/07/17 02:45:05 jsg Exp $ */
/* $NetBSD: sitara_cm.c,v 1.1 2013/04/17 14:31:02 bouyer Exp $ */
/*
* Copyright (c) 2010
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <armv7/omap/sitara_cm.h>
#include <armv7/omap/sitara_cmreg.h>
+#include <dev/ofw/openfirm.h>
+
void sitara_cm_attach(struct device *parent, struct device *self, void *aux);
+int sitara_cm_pinctrl(uint32_t);
struct sitara_cm_softc {
struct device sc_dev;
printf(": control module, rev %d.%d\n",
SCM_REVISION_MAJOR(rev), SCM_REVISION_MINOR(rev));
}
+
+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)
+{
+ struct sitara_cm_softc *sc = sitara_cm_sc;
+ uint32_t *pins;
+ int npins;
+ int node;
+ int len;
+ int i, j;
+
+ if (sc == NULL)
+ return -1;
+
+ node = OF_getnodebyphandle(phandle);
+ if (node == 0)
+ return -1;
+
+ len = OF_getproplen(node, "pinctrl-single,pins");
+ if (len <= 0)
+ return -1;
+
+ pins = malloc(len, M_TEMP, M_WAITOK);
+ OF_getpropintarray(node, "pinctrl-single,pins", pins, len);
+ npins = len / (2 * sizeof(uint32_t));
+
+ for (i = 0, j = 0; i < npins; i++, j += 2) {
+ uint32_t conf_reg = SCM_PINMUX + pins[2 * i + 0];
+ uint32_t conf_val = pins[2 * i + 1];
+
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, conf_reg, conf_val);
+ }
+
+ free(pins, M_TEMP, len);
+ return 0;
+}
-/* $OpenBSD: sitara_cm.h,v 1.1 2013/09/04 14:38:32 patrick Exp $ */
+/* $OpenBSD: sitara_cm.h,v 1.2 2016/07/17 02:45:05 jsg Exp $ */
/* $NetBSD: sitara_cm.h,v 1.1 2013/04/17 14:31:02 bouyer Exp $ */
/*
* Copyright (c) 2010
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_ */
-/* $OpenBSD: sitara_cmreg.h,v 1.1 2013/09/04 14:38:32 patrick Exp $ */
+/* $OpenBSD: sitara_cmreg.h,v 1.2 2016/07/17 02:45:05 jsg Exp $ */
/* $NetBSD: sitara_cmreg.h,v 1.1 2013/04/17 15:04:39 bouyer Exp $ */
/*
#define SCM_REVISION_CUSTOM(x) (((x) & 0x000000c0) >> 6)
#define SCM_REVISION_MINOR(x) (((x) & 0x0000001f) >> 0)
+#define SCM_PINMUX 0x800
+
#define OMAP2SCM_MAC_ID0_LO 0x630
#define OMAP2SCM_MAC_ID0_HI 0x634
-/* $OpenBSD: ti_iic.c,v 1.5 2016/06/26 07:25:05 jsg Exp $ */
+/* $OpenBSD: ti_iic.c,v 1.6 2016/07/17 02:45:05 jsg Exp $ */
/* $NetBSD: ti_iic.c,v 1.4 2013/04/25 13:04:27 rkujawa Exp $ */
/*
#include <armv7/armv7/armv7var.h>
#include <armv7/omap/prcmvar.h>
-#include <armv7/omap/sitara_cm.h>
-#include <armv7/omap/sitara_cmreg.h>
#include <armv7/omap/ti_iicreg.h>
+#include <armv7/omap/sitara_cm.h>
#include <dev/ofw/openfirm.h>
struct fdt_attach_args *faa = aux;
struct i2cbus_attach_args iba;
uint16_t rev;
- const char *mode;
- u_int state;
int irq, unit, len;
- char buf[20];
char hwmods[128];
- char *pin;
- /* BBB specific pin names */
- char *pins[6] = {"I2C0_SDA", "I2C0_SCL",
- "SPIO_D1", "SPI0_CS0",
- "UART1_CTSn", "UART1_RTSn"};
if (faa->fa_nreg != 2 || (faa->fa_nintr != 1 && faa->fa_nintr != 3))
return;
faa->fa_reg[1], 0, &sc->sc_ioh))
panic("%s: bus_space_map failed!", DEVNAME(sc));
+ sitara_cm_pinctrlbyname(faa->fa_node, "default");
+
sc->sc_ih = arm_intr_establish(irq, IPL_NET,
ti_iic_intr, sc, DEVNAME(sc));
prcm_enablemodule(PRCM_I2C0 + unit);
- if (board_id == BOARD_ID_AM335X_BEAGLEBONE) {
- pin = pins[unit * 2];
- snprintf(buf, sizeof buf, "I2C%d_SDA", unit);
- if (sitara_cm_padconf_set(pin, buf,
- (0x01 << 4) | (0x01 << 5) | (0x01 << 6)) != 0) {
- printf(": can't switch %s pad\n", buf);
- return;
- }
- if (sitara_cm_padconf_get(pin, &mode, &state) == 0) {
- printf(": %s state %d ", mode, state);
- }
-
- pin = pins[unit * 2 + 1];
- snprintf(buf, sizeof buf, "I2C%d_SCL", unit);
- if (sitara_cm_padconf_set(pin, buf,
- (0x01 << 4) | (0x01 << 5) | (0x01 << 6)) != 0) {
- printf(": can't switch %s pad\n", buf);
- return;
- }
- if (sitara_cm_padconf_get(pin, &mode, &state) == 0) {
- printf(": %s state %d ", mode, state);
- }
- }
-
rev = I2C_READ_REG(sc, AM335X_I2C_REVNB_LO);
printf(" rev %d.%d\n",
(int)I2C_REVNB_LO_MAJOR(rev),