Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174350076
D60206.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D60206.diff
View Options
diff --git a/sys/arm/ti/am335x/am335x_dmtimer.c b/sys/arm/ti/am335x/am335x_dmtimer.c
--- a/sys/arm/ti/am335x/am335x_dmtimer.c
+++ b/sys/arm/ti/am335x/am335x_dmtimer.c
@@ -312,7 +312,7 @@
}
/* Enable clocks and power on the device. */
- err = ti_sysc_clock_enable(device_get_parent(dev));
+ err = ti_sysc_clock_enable(device_get_parent(dev), "fck");
if (err != 0) {
device_printf(dev, "Cant enable sysc clkctrl, err %d\n", err);
return (ENXIO);
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
@@ -499,7 +499,7 @@
}
/* Enable clocks and power on the device. */
- err = ti_sysc_clock_enable(device_get_parent(dev));
+ err = ti_sysc_clock_enable(device_get_parent(dev), "fck");
if (err != 0) {
device_printf(dev, "Cant enable sysc clkctrl, err %d\n", err);
return (ENXIO);
diff --git a/sys/arm/ti/am335x/am335x_lcd.c b/sys/arm/ti/am335x/am335x_lcd.c
--- a/sys/arm/ti/am335x/am335x_lcd.c
+++ b/sys/arm/ti/am335x/am335x_lcd.c
@@ -1002,7 +1002,7 @@
}
}
- err = ti_sysc_clock_enable(device_get_parent(dev));
+ err = ti_sysc_clock_enable(device_get_parent(dev), "fck");
if (err != 0) {
device_printf(dev, "Failed to enable sysc clkctrl, err %d\n", err);
return (ENXIO);
diff --git a/sys/arm/ti/am335x/am335x_pwmss.c b/sys/arm/ti/am335x/am335x_pwmss.c
--- a/sys/arm/ti/am335x/am335x_pwmss.c
+++ b/sys/arm/ti/am335x/am335x_pwmss.c
@@ -121,7 +121,7 @@
return (ENXIO);
}
- ti_sysc_clock_enable(device_get_parent(dev));
+ ti_sysc_clock_enable(device_get_parent(dev), "fck");
rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
switch (rev_address) {
diff --git a/sys/arm/ti/am335x/am335x_rtc.c b/sys/arm/ti/am335x/am335x_rtc.c
--- a/sys/arm/ti/am335x/am335x_rtc.c
+++ b/sys/arm/ti/am335x/am335x_rtc.c
@@ -108,7 +108,7 @@
RTC_LOCK_INIT(sc);
/* Enable the RTC module. */
- ti_sysc_clock_enable(device_get_parent(dev));
+ ti_sysc_clock_enable(device_get_parent(dev), "fck");
rev = RTC_READ4(sc, RTC_REVISION);
device_printf(dev, "AM335X RTC v%d.%d.%d\n",
(rev >> 8) & 0x7, (rev >> 6) & 0x3, rev & 0x3f);
diff --git a/sys/arm/ti/ti_adc.c b/sys/arm/ti/ti_adc.c
--- a/sys/arm/ti/ti_adc.c
+++ b/sys/arm/ti/ti_adc.c
@@ -733,6 +733,8 @@
static int
ti_adc_probe(device_t dev)
{
+ if (ofw_bus_status_okay(dev) == 0)
+ return (ENXIO);
if (!ofw_bus_is_compatible(dev, "ti,am3359-tscadc"))
return (ENXIO);
@@ -820,7 +822,7 @@
}
/* Activate the ADC_TSC module. */
- err = ti_sysc_clock_enable(device_get_parent(dev));
+ err = ti_sysc_clock_enable(device_get_parent(dev), "fck");
if (err)
return (err);
diff --git a/sys/arm/ti/ti_edma3.c b/sys/arm/ti/ti_edma3.c
--- a/sys/arm/ti/ti_edma3.c
+++ b/sys/arm/ti/ti_edma3.c
@@ -181,7 +181,7 @@
/* FIXME: Require DTS from Linux kernel 5.7 */
/* FIXME: OK to enable clkctrl here? */
/* Enable Channel Controller */
- ti_sysc_clock_enable(device_get_parent(dev));
+ ti_sysc_clock_enable(device_get_parent(dev), "fck");
reg = ti_edma3_cc_rd_4(TI_EDMA3CC_PID);
diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c
--- a/sys/arm/ti/ti_gpio.c
+++ b/sys/arm/ti/ti_gpio.c
@@ -42,9 +42,9 @@
#include <sys/mutex.h>
#include <sys/gpio.h>
#include <sys/interrupt.h>
+#include <sys/intr.h>
#include <machine/bus.h>
-#include <machine/intr.h>
#include <machine/resource.h>
#include <arm/ti/ti_cpuid.h>
@@ -557,7 +557,7 @@
}
#endif
}
- err = ti_sysc_clock_enable(device_get_parent(dev));
+ err = ti_sysc_clock_enable(device_get_parent(dev), "fck");
if (err) {
device_printf(dev, "Failed to enable clock\n");
return (EINVAL);
diff --git a/sys/arm/ti/ti_i2c.c b/sys/arm/ti/ti_i2c.c
--- a/sys/arm/ti/ti_i2c.c
+++ b/sys/arm/ti/ti_i2c.c
@@ -660,10 +660,10 @@
sc = (struct ti_i2c_softc*)device_get_softc(dev);
/*
- * 1. Enable the functional and interface clocks (see Section
+ * 1. Enable the functional clocks (see Section
* 23.1.5.1.1.1.1).
*/
- err = ti_sysc_clock_enable(device_get_parent(dev));
+ err = ti_sysc_clock_enable(device_get_parent(dev), "fck");
if (err)
return (err);
@@ -710,8 +710,8 @@
sc->sc_irq_res = NULL;
}
- /* Finally disable the functional and interface clocks. */
- ti_sysc_clock_disable(device_get_parent(dev));
+ /* Finally disable the functional clocks. */
+ ti_sysc_clock_disable(device_get_parent(dev), "fck");
}
static int
diff --git a/sys/arm/ti/ti_mbox.c b/sys/arm/ti/ti_mbox.c
--- a/sys/arm/ti/ti_mbox.c
+++ b/sys/arm/ti/ti_mbox.c
@@ -134,7 +134,7 @@
int rid, delay, chan;
uint32_t rev, sysconfig;
- if (ti_sysc_clock_enable(device_get_parent(dev)) != 0) {
+ if (ti_sysc_clock_enable(device_get_parent(dev), "fck") != 0) {
device_printf(dev, "could not enable MBOX clock\n");
return (ENXIO);
}
diff --git a/sys/arm/ti/ti_pruss.c b/sys/arm/ti/ti_pruss.c
--- a/sys/arm/ti/ti_pruss.c
+++ b/sys/arm/ti/ti_pruss.c
@@ -533,7 +533,7 @@
/* Set MODULEMODE to ENABLE(2) */
/* Wait for MODULEMODE to become ENABLE(2) */
- if (ti_sysc_clock_enable(device_get_parent(dev)) != 0) {
+ if (ti_sysc_clock_enable(device_get_parent(dev), "fck") != 0) {
device_printf(dev, "Could not enable PRUSS clock\n");
return (ENXIO);
}
diff --git a/sys/arm/ti/ti_sdhci.c b/sys/arm/ti/ti_sdhci.c
--- a/sys/arm/ti/ti_sdhci.c
+++ b/sys/arm/ti/ti_sdhci.c
@@ -419,8 +419,8 @@
clk_t mmc_clk;
int err;
- /* Enable the controller and interface/functional clocks */
- if (ti_sysc_clock_enable(device_get_parent(dev)) != 0) {
+ /* Enable the controller and functional clocks */
+ if (ti_sysc_clock_enable(device_get_parent(dev), "fck") != 0) {
device_printf(dev, "Error: failed to enable MMC clock\n");
return (ENXIO);
}
diff --git a/sys/arm/ti/ti_spi.c b/sys/arm/ti/ti_spi.c
--- a/sys/arm/ti/ti_spi.c
+++ b/sys/arm/ti/ti_spi.c
@@ -171,7 +171,7 @@
sc->sc_dev = dev;
/* Activate the McSPI module. */
- err = ti_sysc_clock_enable(device_get_parent(dev));
+ err = ti_sysc_clock_enable(device_get_parent(dev), "fck");
if (err) {
device_printf(dev, "Error: failed to activate source clock\n");
return (err);
diff --git a/sys/arm/ti/ti_sysc.h b/sys/arm/ti/ti_sysc.h
--- a/sys/arm/ti/ti_sysc.h
+++ b/sys/arm/ti/ti_sysc.h
@@ -33,8 +33,8 @@
uint64_t ti_sysc_get_sysc_address_offset_host(device_t dev);
uint64_t ti_sysc_get_syss_address(device_t dev);
uint64_t ti_sysc_get_syss_address_offset_host(device_t dev);
-int ti_sysc_clock_enable(device_t dev);
-int ti_sysc_clock_disable(device_t dev);
+int ti_sysc_clock_enable(device_t dev, const char *clk_name);
+int ti_sysc_clock_disable(device_t dev, const char *clk_name);
uint32_t ti_sysc_get_soft_reset_bit(device_t dev);
diff --git a/sys/arm/ti/ti_sysc.c b/sys/arm/ti/ti_sysc.c
--- a/sys/arm/ti/ti_sysc.c
+++ b/sys/arm/ti/ti_sysc.c
@@ -64,10 +64,6 @@
* Documentation/devicetree/clock/ti-clkctl.txt
*/
-static int ti_sysc_probe(device_t dev);
-static int ti_sysc_attach(device_t dev);
-static int ti_sysc_detach(device_t dev);
-
#define TI_SYSC_DRA7_MCAN 15
#define TI_SYSC_USB_HOST_FS 14
#define TI_SYSC_DRA7_MCASP 13
@@ -143,6 +139,7 @@
int num_clocks;
TAILQ_HEAD(, clk_list) clk_list;
+ const char **clk_names;
/* deprecated ti_hwmods */
bool ti_no_reset_on_init;
@@ -150,6 +147,11 @@
bool ti_no_idle;
};
+static int ti_sysc_probe(device_t dev);
+static int ti_sysc_attach(device_t dev);
+static int ti_sysc_detach(device_t dev);
+static void ti_parse_clocks(struct ti_sysc_softc *);
+
/*
* All sysc seems to have a reg["rev"] register.
* Lets use that for identification of which module the driver are connected to.
@@ -228,41 +230,127 @@
}
int
-ti_sysc_clock_enable(device_t dev) {
+ti_sysc_clock_enable(device_t dev, const char *clk_name) {
struct clk_list *clkp, *clkp_tmp;
struct ti_sysc_softc *sc = device_get_softc(dev);
- int err;
+ int err = ENOENT, index=0;
+
+ // Find clocks if they is not already found.
+ if (sc->num_clocks == -1)
+ ti_parse_clocks(sc);
+
+ // Still no clocks?
+ if (sc->num_clocks == 0) {
+ panic("Cant find clocks for ti_sysc %s\n",
+ ofw_bus_get_name(dev));
+ }
TAILQ_FOREACH_SAFE(clkp, &sc->clk_list, next, clkp_tmp) {
+ if (strcmp(sc->clk_names[index], clk_name) != 0) {
+ index++;
+ continue;
+ }
err = clk_enable(clkp->clk);
- if (err) {
+ if (err != 0) {
DPRINTF(sc->dev, "clk_enable %s failed %d\n",
clk_get_name(clkp->clk), err);
break;
}
+ DPRINTF(sc->dev, "clk_enable %s\n",
+ clk_get_name(clkp->clk));
+ break;
}
+
return (err);
}
int
-ti_sysc_clock_disable(device_t dev) {
+ti_sysc_clock_disable(device_t dev, const char *clk_name) {
struct clk_list *clkp, *clkp_tmp;
struct ti_sysc_softc *sc = device_get_softc(dev);
- int err = 0;
+ int err = ENOENT, index = 0;
+
+ // Find clocks if they is not already found.
+ if (sc->num_clocks == -1)
+ ti_parse_clocks(sc);
+
+ // Still no clocks?
+ if (sc->num_clocks == 0) {
+ panic("Cant find clocks for ti_sysc %s\n",
+ ofw_bus_get_name(dev));
+ }
TAILQ_FOREACH_SAFE(clkp, &sc->clk_list, next, clkp_tmp) {
+ if (strcmp(sc->clk_names[index], clk_name) != 0) {
+ index++;
+ continue;
+ }
+
err = clk_disable(clkp->clk);
- if (err) {
- DPRINTF(sc->dev, "clk_enable %s failed %d\n",
+ if (err != 0) {
+ DPRINTF(sc->dev, "clk_disable %s failed %d\n",
clk_get_name(clkp->clk), err);
break;
}
+ DPRINTF(sc->dev, "clk_disable %s\n",
+ clk_get_name(clkp->clk));
+ break;
}
+
return (err);
}
+static void
+ti_parse_clocks(struct ti_sysc_softc *sc)
+{
+ phandle_t node;
+ int err, num_clocks, num_clock_names;
+
+ sc->num_clocks = 0;
+ node = ofw_bus_get_node(sc->dev);
+ if (OF_hasprop(node, "clocks") == 0) {
+ return;
+ }
+
+ err = ofw_bus_parse_xref_list_get_length(node, "clocks",
+ "#clock-cells", &num_clocks);
+
+ if (err != 0)
+ return;
+ if (num_clocks == 0)
+ return;
+
+ num_clock_names = ofw_bus_string_list_to_array(node, "clock-names",
+ &sc->clk_names);
+ if (num_clocks != num_clock_names)
+ {
+ panic("%s: Number of clocks isnt equal to number of clock-names\n",
+ ofw_bus_get_name(sc->dev));
+ }
+
+ TAILQ_INIT(&sc->clk_list);
+ for (int clk_index = 0; clk_index < num_clocks; clk_index++) {
+ struct clk_list *clkp;
+ clkp = malloc(sizeof(*clkp), M_DEVBUF,
+ M_WAITOK | M_ZERO);
+ err = clk_get_by_ofw_index(sc->dev, node, clk_index,
+ &clkp->clk);
+ if (err != 0) {
+ panic("Failed to find clock %s in ti,sysc %s\n",
+ sc->clk_names[clk_index],
+ ofw_bus_get_name(sc->dev));
+ }
+
+ DPRINTF(sc->dev, "node %s has clk: %s clk_name: %s\n",
+ ofw_bus_get_name(sc->dev), clk_get_name(clkp->clk),
+ sc->clk_names[clk_index]);
+ TAILQ_INSERT_TAIL(&sc->clk_list, clkp, next);
+ sc->num_clocks++;
+ }
+}
+
static int
parse_regfields(struct ti_sysc_softc *sc, struct simplebus_softc *sb_sc) {
phandle_t node;
diff --git a/sys/dev/uart/uart_dev_ti8250.c b/sys/dev/uart/uart_dev_ti8250.c
--- a/sys/dev/uart/uart_dev_ti8250.c
+++ b/sys/dev/uart/uart_dev_ti8250.c
@@ -71,7 +71,8 @@
{
int status;
- if ((status = ti_sysc_clock_enable(device_get_parent(sc->sc_dev))) != 0)
+ status = ti_sysc_clock_enable(device_get_parent(sc->sc_dev), "fck");
+ if (status != 0)
return (status);
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 3, 2:57 PM (13 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40129577
Default Alt Text
D60206.diff (11 KB)
Attached To
Mode
D60206: TI AM335x: ti_sysc enable/disable specific clocks
Attached
Detach File
Event Timeline
Log In to Comment