Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111493666
D46744.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D46744.diff
View Options
diff --git a/sys/arm/ti/am335x/am335x_dmtpps.c b/sys/arm/ti/am335x/am335x_dmtpps.c
--- a/sys/arm/ti/am335x/am335x_dmtpps.c
+++ b/sys/arm/ti/am335x/am335x_dmtpps.c
@@ -63,8 +63,6 @@
#include <dev/clk/clk.h>
#include <arm/ti/ti_sysc.h>
-#include <arm/ti/ti_pinmux.h>
-#include <arm/ti/am335x/am335x_scm_padconf.h>
#include "am335x_dmtreg.h"
@@ -74,7 +72,7 @@
device_t dev;
int mem_rid;
struct resource * mem_res;
- int tmr_num; /* N from hwmod str "timerN" */
+ int tmr_num; /* N from reg address */
char tmr_name[12]; /* "DMTimerN" */
uint32_t tclr; /* Cached TCLR register. */
struct timecounter tc;
@@ -86,163 +84,16 @@
uint64_t sysclk_freq;
};
-static int dmtpps_tmr_num; /* Set by probe() */
-
/* List of compatible strings for FDT tree */
static struct ofw_compat_data compat_data[] = {
- {"ti,am335x-timer", 1},
- {"ti,am335x-timer-1ms", 1},
+ {"ti,am335x-timer-dmtpps", 1},
{NULL, 0},
};
SIMPLEBUS_PNP_INFO(compat_data);
-/*
- * A table relating pad names to the hardware timer number they can be mux'd to.
- */
-struct padinfo {
- char * ballname;
- int tmr_num;
-};
-static struct padinfo dmtpps_padinfo[] = {
- {"GPMC_ADVn_ALE", 4},
- {"I2C0_SDA", 4},
- {"MII1_TX_EN", 4},
- {"XDMA_EVENT_INTR0", 4},
- {"GPMC_BEn0_CLE", 5},
- {"MDC", 5},
- {"MMC0_DAT3", 5},
- {"UART1_RTSn", 5},
- {"GPMC_WEn", 6},
- {"MDIO", 6},
- {"MMC0_DAT2", 6},
- {"UART1_CTSn", 6},
- {"GPMC_OEn_REn", 7},
- {"I2C0_SCL", 7},
- {"UART0_CTSn", 7},
- {"XDMA_EVENT_INTR1", 7},
- {NULL, 0}
-};
-
-/*
- * This is either brilliantly user-friendly, or utterly lame...
- *
- * The am335x chip is used on the popular Beaglebone boards. Those boards have
- * pins for all four capture-capable timers available on the P8 header. Allow
- * users to configure the input pin by giving the name of the header pin.
- */
-struct nicknames {
- const char * nick;
- const char * name;
-};
-static struct nicknames dmtpps_pin_nicks[] = {
- {"P8-7", "GPMC_ADVn_ALE"},
- {"P8-9", "GPMC_BEn0_CLE"},
- {"P8-10", "GPMC_WEn"},
- {"P8-8", "GPMC_OEn_REn",},
- {NULL, NULL}
-};
-
#define DMTIMER_READ4(sc, reg) bus_read_4((sc)->mem_res, (reg))
#define DMTIMER_WRITE4(sc, reg, val) bus_write_4((sc)->mem_res, (reg), (val))
-/*
- * Translate a short friendly case-insensitive name to its canonical name.
- */
-static const char *
-dmtpps_translate_nickname(const char *nick)
-{
- struct nicknames *nn;
-
- for (nn = dmtpps_pin_nicks; nn->nick != NULL; nn++)
- if (strcasecmp(nick, nn->nick) == 0)
- return nn->name;
- return (nick);
-}
-
-/*
- * See if our tunable is set to the name of the input pin. If not, that's NOT
- * an error, return 0. If so, try to configure that pin as a timer capture
- * input pin, and if that works, then we have our timer unit number and if it
- * fails that IS an error, return -1.
- */
-static int
-dmtpps_find_tmr_num_by_tunable(void)
-{
- struct padinfo *pi;
- char iname[20];
- char muxmode[12];
- const char * ballname;
- int err;
-
- if (!TUNABLE_STR_FETCH("hw.am335x_dmtpps.input", iname, sizeof(iname)))
- return (0);
- ballname = dmtpps_translate_nickname(iname);
- for (pi = dmtpps_padinfo; pi->ballname != NULL; pi++) {
- if (strcmp(ballname, pi->ballname) != 0)
- continue;
- snprintf(muxmode, sizeof(muxmode), "timer%d", pi->tmr_num);
- err = ti_pinmux_padconf_set(pi->ballname, muxmode,
- PADCONF_INPUT);
- if (err != 0) {
- printf("am335x_dmtpps: unable to configure capture pin "
- "for %s to input mode\n", muxmode);
- return (-1);
- } else if (bootverbose) {
- printf("am335x_dmtpps: configured pin %s as input "
- "for %s\n", iname, muxmode);
- }
- return (pi->tmr_num);
- }
-
- /* Invalid name in the tunable, that's an error. */
- printf("am335x_dmtpps: unknown pin name '%s'\n", iname);
- return (-1);
-}
-
-/*
- * Ask the pinmux driver whether any pin has been configured as a TIMER4..TIMER7
- * input pin. If so, return the timer number, if not return 0.
- */
-static int
-dmtpps_find_tmr_num_by_padconf(void)
-{
- int err;
- unsigned int padstate;
- const char * padmux;
- struct padinfo *pi;
- char muxmode[12];
-
- for (pi = dmtpps_padinfo; pi->ballname != NULL; pi++) {
- err = ti_pinmux_padconf_get(pi->ballname, &padmux, &padstate);
- snprintf(muxmode, sizeof(muxmode), "timer%d", pi->tmr_num);
- if (err == 0 && (padstate & RXACTIVE) != 0 &&
- strcmp(muxmode, padmux) == 0)
- return (pi->tmr_num);
- }
- /* Nothing found, not an error. */
- return (0);
-}
-
-/*
- * Figure out which hardware timer number to use based on input pin
- * configuration. This is done just once, the first time probe() runs.
- */
-static int
-dmtpps_find_tmr_num(void)
-{
- int tmr_num;
-
- if ((tmr_num = dmtpps_find_tmr_num_by_tunable()) == 0)
- tmr_num = dmtpps_find_tmr_num_by_padconf();
-
- if (tmr_num <= 0) {
- printf("am335x_dmtpps: PPS driver not enabled: unable to find "
- "or configure a capture input pin\n");
- tmr_num = -1; /* Must return non-zero to prevent re-probing. */
- }
- return (tmr_num);
-}
-
static void
dmtpps_set_hw_capture(struct dmtpps_softc *sc, bool force_off)
{
@@ -392,29 +243,12 @@
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
- /*
- * If we haven't chosen which hardware timer to use yet, go do that now.
- * We need to know that to decide whether to return success for this
- * hardware timer instance or not.
- */
- if (dmtpps_tmr_num == 0)
- dmtpps_tmr_num = dmtpps_find_tmr_num();
-
/*
* Figure out which hardware timer is being probed and see if it matches
* the configured timer number determined earlier.
*/
rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
switch (rev_address) {
- case DMTIMER1_1MS_REV:
- tmr_num = 1;
- break;
- case DMTIMER2_REV:
- tmr_num = 2;
- break;
- case DMTIMER3_REV:
- tmr_num = 3;
- break;
case DMTIMER4_REV:
tmr_num = 4;
break;
@@ -431,9 +265,6 @@
return (ENXIO);
}
- if (dmtpps_tmr_num != tmr_num)
- return (ENXIO);
-
device_set_descf(dev, "AM335x PPS-Capture DMTimer%d", tmr_num);
if (bootverbose == 0)
device_quiet(dev);
@@ -456,15 +287,6 @@
/* Figure out which hardware timer this is and set the name string. */
rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
switch (rev_address) {
- case DMTIMER1_1MS_REV:
- sc->tmr_num = 1;
- break;
- case DMTIMER2_REV:
- sc->tmr_num = 2;
- break;
- case DMTIMER3_REV:
- sc->tmr_num = 3;
- break;
case DMTIMER4_REV:
sc->tmr_num = 4;
break;
@@ -523,7 +345,7 @@
/*
* Configure the timer pulse/capture pin to input/capture mode. This is
* required in addition to configuring the pin as input with the pinmux
- * controller (which was done via fdt data or tunable at probe time).
+ * controller (which was done via fdt data).
*/
sc->tclr = DMT_TCLR_GPO_CFG;
DMTIMER_WRITE4(sc, DMT_TCLR, sc->tclr);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 11:32 AM (14 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16991377
Default Alt Text
D46744.diff (6 KB)
Attached To
Mode
D46744: am335x_dmttps.c remove dependency of ti_pinmux&am335x_scm_padconf
Attached
Detach File
Event Timeline
Log In to Comment