socsvn commit: r240361 - in soc2012/aleek/beaglexm-armv6/sys:
arm/ti arm/ti/twl arm/ti/usb boot/fdt/dts
aleek at FreeBSD.org
aleek at FreeBSD.org
Tue Aug 14 23:28:36 UTC 2012
Author: aleek
Date: Tue Aug 14 23:28:33 2012
New Revision: 240361
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240361
Log:
fix some bugs in TWL driver. I am trying to initialize TWL during the bootup
Modified:
soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c
soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c
soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c
soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c
soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_usb.h
soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts
Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c Tue Aug 14 22:34:22 2012 (r240360)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/ti_i2c.c Tue Aug 14 23:28:33 2012 (r240361)
@@ -180,6 +180,7 @@
static inline uint16_t
ti_i2c_read_2(struct ti_i2c_softc *sc, bus_size_t off)
{
+ device_printf(sc->sc_dev, "%s\n", __func__);
return bus_read_2(sc->sc_mem_res, off);
}
@@ -198,6 +199,7 @@
static inline void
ti_i2c_write_2(struct ti_i2c_softc *sc, bus_size_t off, uint16_t val)
{
+ device_printf(sc->sc_dev, "%s\n", __func__);
bus_write_2(sc->sc_mem_res, off, val);
}
@@ -217,6 +219,7 @@
static inline uint16_t
ti_i2c_read_reg(struct ti_i2c_softc *sc, bus_size_t off)
{
+ device_printf(sc->sc_dev, "%s\n", __func__);
return bus_read_2(sc->sc_mem_res, off);
}
@@ -236,6 +239,7 @@
static inline void
ti_i2c_write_reg(struct ti_i2c_softc *sc, bus_size_t off, uint16_t val)
{
+ device_printf(sc->sc_dev, "%s\n", __func__);
bus_write_2(sc->sc_mem_res, off, val);
}
@@ -285,6 +289,8 @@
struct ti_i2c_clock_config *clkcfg;
uint16_t con_reg;
+ device_printf(dev, "%s\n", __func__);
+
clkcfg = ti_i2c_clock_configs;
while (clkcfg->speed != -1) {
if (clkcfg->speed == speed)
@@ -349,6 +355,8 @@
struct ti_i2c_softc *sc = (struct ti_i2c_softc*) arg;
uint16_t status;
+ device_printf(sc->sc_dev, "%s\n", __func__);
+
status = ti_i2c_read_reg(sc, I2C_REG_STAT);
if (status == 0)
return;
@@ -746,6 +754,8 @@
uint16_t len;
uint8_t *buf;
+ device_printf(sc->sc_dev, "%s\n", __func__);
+
TI_I2C_LOCK(sc);
for (i = 0; i < nmsgs; i++) {
@@ -793,6 +803,7 @@
ti_i2c_callback(device_t dev, int index, caddr_t data)
{
int error = 0;
+ device_printf(dev, "%s\n", __func__);
switch (index) {
case IIC_REQUEST_BUS:
Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c Tue Aug 14 22:34:22 2012 (r240360)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl.c Tue Aug 14 23:28:33 2012 (r240361)
@@ -177,6 +177,7 @@
int rc;
sc = device_get_softc(dev);
+ device_printf(sc->sc_dev, "%s\n", __func__);
TWL_LOCK(sc);
addr = sc->sc_subaddr_map[nsub];
@@ -237,6 +238,7 @@
memcpy(&tmp_buf[1], buf, cnt);
sc = device_get_softc(dev);
+ device_printf(sc->sc_dev, "%s\n", __func__);
TWL_LOCK(sc);
addr = sc->sc_subaddr_map[nsub];
@@ -328,7 +330,7 @@
TWL_UNLOCK(sc);
/* Finished with the interrupt hook */
- config_intrhook_disestablish(&sc->sc_scan_hook);
+ //config_intrhook_disestablish(&sc->sc_scan_hook);
}
/**
@@ -412,11 +414,12 @@
/* We have to wait until interrupts are enabled. I2C read and write
* only works if the interrupts are available.
*/
- sc->sc_scan_hook.ich_func = twl_scan;
- sc->sc_scan_hook.ich_arg = dev;
+ //sc->sc_scan_hook.ich_func = twl_scan;
+ //sc->sc_scan_hook.ich_arg = dev;
- if (config_intrhook_establish(&sc->sc_scan_hook) != 0)
- return (ENOMEM);
+ //if (config_intrhook_establish(&sc->sc_scan_hook) != 0)
+ // return (ENOMEM);
+ twl_scan( dev );
/* FIXME: should be in DTS file */
if ((sc->sc_vreg = device_add_child(dev, "twl_vreg", -1)) == NULL)
Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Tue Aug 14 22:34:22 2012 (r240360)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Tue Aug 14 23:28:33 2012 (r240361)
@@ -231,7 +231,7 @@
LIST_HEAD(twl_regulator_list, twl_regulator_entry) sc_vreg_list;
};
-
+#if 1
#define TWL_VREG_XLOCK(_sc) sx_xlock(&(_sc)->sc_sx)
#define TWL_VREG_XUNLOCK(_sc) sx_xunlock(&(_sc)->sc_sx)
#define TWL_VREG_SLOCK(_sc) sx_slock(&(_sc)->sc_sx)
@@ -247,7 +247,21 @@
pause("twl_vreg_ex", (hz / 100)); \
} while(0)
#define TWL_VREG_LOCK_DOWNGRADE(_sc) sx_downgrade(&(_sc)->sc_sx);
+#endif
+#if 0
+#define TWL_VREG_XLOCK(_sc)
+#define TWL_VREG_XUNLOCK(_sc)
+#define TWL_VREG_SLOCK(_sc)
+#define TWL_VREG_SUNLOCK(_sc)
+#define TWL_VREG_LOCK_INIT(_sc)
+#define TWL_VREG_LOCK_DESTROY(_sc)
+
+#define TWL_VREG_ASSERT_LOCKED(_sc)
+
+#define TWL_VREG_LOCK_UPGRADE(_sc)
+#define TWL_VREG_LOCK_DOWNGRADE(_sc)
+#endif
@@ -266,6 +280,7 @@
twl_vreg_read_1(struct twl_vreg_softc *sc, struct twl_regulator_entry *regulator,
uint8_t off, uint8_t *val)
{
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, regulator->name);
return (twl_read(sc->sc_pdev, regulator->sub_dev,
regulator->reg_off + off, val, 1));
}
@@ -274,6 +289,7 @@
twl_vreg_write_1(struct twl_vreg_softc *sc, struct twl_regulator_entry *regulator,
uint8_t off, uint8_t val)
{
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, regulator->name);
return (twl_write(sc->sc_pdev, regulator->sub_dev,
regulator->reg_off + off, &val, 1));
}
@@ -357,6 +373,8 @@
uint8_t state;
int xlocked;
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, regulator->name);
+
if (enabled == NULL)
return (EINVAL);
@@ -430,6 +448,8 @@
uint8_t grp;
int xlocked;
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, regulator->name);
+
TWL_VREG_ASSERT_LOCKED(sc);
xlocked = sx_xlocked(&sc->sc_sx);
@@ -493,6 +513,8 @@
uint8_t grp;
int xlocked;
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, regulator->name);
+
TWL_VREG_ASSERT_LOCKED(sc);
xlocked = sx_xlocked(&sc->sc_sx);
@@ -559,6 +581,8 @@
uint8_t vsel;
int xlocked;
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, regulator->name);
+
TWL_VREG_ASSERT_LOCKED(sc);
/* If millivolts is zero then we simply disable the output */
@@ -627,20 +651,29 @@
int xlocked;
uint8_t vsel;
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, regulator->name);
TWL_VREG_ASSERT_LOCKED(sc);
+ //device_printf(sc->sc_dev, "%s:%d\n", __func__, __LINE__);
/* Need to upgrade the lock because checking enabled state and voltage
* should be atomic.
*/
+ //device_printf(sc->sc_dev, "%s:%d\n", __func__, __LINE__);
xlocked = sx_xlocked(&sc->sc_sx);
if (!xlocked)
TWL_VREG_LOCK_UPGRADE(sc);
+ //device_printf(sc->sc_dev, "%s:%d\n", __func__, __LINE__);
/* Check if the regulator is currently enabled */
+ //device_printf(sc->sc_dev, "%s:%d\n", __func__, __LINE__);
err = twl_vreg_is_regulator_enabled(sc, regulator, &en);
if (err)
+ {
+ device_printf( sc->sc_dev, "Regulator %s is not enabled\n", regulator->name );
goto done;
+ }
+ //device_printf(sc->sc_dev, "%s:%d\n", __func__, __LINE__);
*millivolts = 0;
if (!en)
@@ -656,10 +689,14 @@
/* For variable voltages read the voltage register */
err = twl_vreg_read_1(sc, regulator, TWL_VREG_VSEL, &vsel);
if (err)
+ {
+ device_printf( sc->sc_dev, "Error Reading %s regulator register\n", regulator->name );
goto done;
+ }
vsel &= (regulator->num_supp_voltages - 1);
if (regulator->supp_voltages[vsel] == UNDF) {
+ device_printf( sc->sc_dev, "siakis inny blad\n" );
err = EINVAL;
goto done;
}
@@ -704,6 +741,8 @@
sc = device_get_softc(dev);
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, name);
+
TWL_VREG_SLOCK(sc);
LIST_FOREACH(regulator, &sc->sc_vreg_list, entries) {
@@ -744,6 +783,8 @@
sc = device_get_softc(dev);
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, name);
+
TWL_VREG_SLOCK(sc);
LIST_FOREACH(regulator, &sc->sc_vreg_list, entries) {
@@ -830,6 +871,8 @@
struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
struct twl_regulator_entry *new;
+ device_printf(sc->sc_dev, "%s - %s\n", __func__, name);
+
new = malloc(sizeof(struct twl_regulator_entry), M_DEVBUF, M_NOWAIT | M_ZERO);
if (new == NULL)
return (NULL);
@@ -846,7 +889,6 @@
new->supp_voltages = voltages;
new->num_supp_voltages = num_voltages;
-
/* Add a sysctl entry for the voltage */
new->oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, name,
CTLTYPE_INT | CTLFLAG_RD, sc, 0,
@@ -887,6 +929,7 @@
int len = 0, prop_len;
+ device_printf(sc->sc_dev, "%s\n", __func__);
/* Add the regulators from the list */
walker = ®ulators[0];
while (walker->name != NULL) {
@@ -901,7 +944,6 @@
walker++;
}
-
/* Check if the FDT is telling us to set any voltages */
child = ofw_bus_get_node(sc->sc_pdev);
if (child) {
@@ -928,7 +970,12 @@
}
}
}
-
+ device_printf(sc->sc_dev, "%s\n", __func__);
+#if 0
+ twl_vreg_set_voltage(sc->sc_dev, "vusb1v5", 1500);
+ twl_vreg_set_voltage(sc->sc_dev, "vusb1v8", 1800);
+ twl_vreg_set_voltage(sc->sc_dev, "vusb3v1", 3100);
+#endif
// if (twl_vreg_debug) { @todo XXX
LIST_FOREACH(entry, &sc->sc_vreg_list, entries) {
@@ -958,6 +1005,7 @@
struct twl_vreg_softc *sc;
sc = device_get_softc((device_t)dev);
+ device_printf(dev, "%s\n", __func__);
TWL_VREG_XLOCK(sc);
@@ -1006,6 +1054,7 @@
if (config_intrhook_establish(&sc->sc_init_hook) != 0)
return (ENOMEM);
+ //twl_vreg_init( dev );
return (0);
}
Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Tue Aug 14 22:34:22 2012 (r240360)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_ehci.c Tue Aug 14 23:28:33 2012 (r240361)
@@ -102,6 +102,9 @@
#include <arm/ti/ti_prcm.h>
#include <arm/ti/ti_scm.h>
+#include <arm/ti/twl/twl.h>
+#include <arm/ti/twl/twl_vreg.h>
+
#include <arm/ti/usb/omap_usb.h>
#include "gpio_if.h"
@@ -111,6 +114,7 @@
device_t sc_dev;
device_t sc_gpio_dev;
+ device_t sc_vreg_dev;
/* TLL register set */
struct resource* tll_mem_res;
@@ -308,13 +312,13 @@
omap_ehci_write_4(isc, OMAP_USBHOST_INSNREG05_ULPI, reg);
+ device_printf(isc->sc_dev, "Waiting for phy reset operation\n");
/* Wait for ULPI access completion */
while ((omap_ehci_read_4(isc, OMAP_USBHOST_INSNREG05_ULPI)
& (1 << OMAP_USBHOST_INSNREG05_ULPI_CONTROL_SHIFT))) {
/* Sleep for a tick */
pause("USBPHY_RESET", 1);
-
if (timeout-- == 0) {
device_printf(isc->sc_dev, "PHY reset operation timed out\n");
break;
@@ -346,9 +350,35 @@
uint32_t reg = 0;
int reset_performed = 0;
int i;
+ //int milivolts;
device_printf(isc->sc_dev, "Starting TI EHCI USB Controller\n");
+ device_printf( isc->sc_dev, "INSNREG05: 0x%08x\n", omap_ehci_read_4(isc, OMAP_USBHOST_INSNREG05_ULPI ) );
+#if 0
+ if( twl_vreg_get_voltage(isc->sc_vreg_dev, "vusb1v5", &milivolts) != 0)
+ {
+ device_printf(isc->sc_dev, "dupa!\n");
+ //return EINVAL;
+ }
+ device_printf( isc->sc_dev, "vusb1v5: %d\n", milivolts );
+ twl_vreg_get_voltage(isc->sc_vreg_dev, "vusb1v8", &milivolts);
+ device_printf( isc->sc_dev, "vusb1v8: %d\n", milivolts );
+ twl_vreg_get_voltage(isc->sc_vreg_dev, "vusb3v1", &milivolts);
+ device_printf( isc->sc_dev, "vusb1v8: %d\n", milivolts );
+
+ twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v5", 1500);
+ twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb1v8", 1800);
+ twl_vreg_set_voltage(isc->sc_vreg_dev, "vusb3v1", 3100);
+ device_printf( isc->sc_dev, "INSNREG05: 0x%08x\n", omap_ehci_read_4(isc, OMAP_USBHOST_INSNREG05_ULPI ) );
+ twl_vreg_get_voltage(isc->sc_vreg_dev, "vusb1v5", &milivolts);
+ device_printf( isc->sc_dev, "vusb1v5: %d\n", milivolts );
+ twl_vreg_get_voltage(isc->sc_vreg_dev, "vusb1v8", &milivolts);
+ device_printf( isc->sc_dev, "vusb1v8: %d\n", milivolts );
+ twl_vreg_get_voltage(isc->sc_vreg_dev, "vusb3v1", &milivolts);
+ device_printf( isc->sc_dev, "vusb1v8: %d\n", milivolts );
+#endif
+
/* Enable Clocks for high speed USBHOST */
ti_prcm_clk_enable(USBHSHOST_CLK);
@@ -381,6 +411,9 @@
/* Enable the USB TLL */
ti_prcm_clk_enable(USBTLL_CLK);
+ //check, if the ph is in suspend mode
+ device_printf( isc->sc_dev, "INSNREG05: 0x%08x\n", omap_ehci_read_4(isc, OMAP_USBHOST_INSNREG05_ULPI ) );
+
/* Set the timeout to 100ms*/
timeout = (hz < 10) ? 1 : ((100 * hz) / 1000);
// perform a uhh reset
@@ -809,6 +842,7 @@
/* save the device */
isc->sc_dev = dev;
+ isc->sc_vreg_dev = devclass_get_device(devclass_find("twl_vreg"), 0);
/* get all DMA memory */
if (usb_bus_mem_alloc_all(&sc->sc_bus, USB_GET_DMA_TAG(dev),
@@ -1046,3 +1080,4 @@
static devclass_t ehci_devclass;
DRIVER_MODULE(ehci, simplebus, ehci_driver, ehci_devclass, 0, 0);
+MODULE_DEPEND(ehci, twl_vreg, 1, 1, 1);
Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_usb.h
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_usb.h Tue Aug 14 22:34:22 2012 (r240360)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/usb/omap_usb.h Tue Aug 14 23:28:33 2012 (r240361)
@@ -132,8 +132,6 @@
-
-
/* TLL Register Set */
#define TLL_SYSCONFIG_CACTIVITY (1UL << 8)
#define TLL_SYSCONFIG_SIDLE_SMART_IDLE (2UL << 3)
@@ -216,6 +214,7 @@
#endif
#define ULPI_FUNC_CTRL_RESET (1 << 5)
+#define ULPI_FUNC_CTRL_SUSPENDM (1 << 6)
/*-------------------------------------------------------------------------*/
Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Tue Aug 14 22:34:22 2012 (r240360)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/dts/beagleboardxm.dts Tue Aug 14 23:28:33 2012 (r240361)
@@ -177,7 +177,7 @@
interrupts = < 12 13 14 15 >;
interrupt-parent = <&AINTC>;
};
-
+/*
mmchs at 4809c000 {
compatible = "ti,mmchs";
reg =<0x4809c000 0x1000 >;
@@ -185,7 +185,7 @@
interrupt-parent = <&AINTC>;
mmchs-device-id = <1>;
};
-
+*/
i2c1: i2c at 48070000 {
#address-cells = <1>;
#size-cells = <0>;
@@ -194,12 +194,14 @@
interrupts = <56>;
interrupt-parent = <&AINTC>;
i2c-device-id = <1>;
- pmic at 48 {
+
+ twl4030 at 48 {
compatible = "ti,twl4030";
reg = <0x48>;
};
};
+/*
ehci at 48064800 {
compatible = "ti,ehci";
/*
@@ -212,17 +214,17 @@
*
* reset indicates (if non-zero) if port reset is required
* gpio_pin - GPIO pin that is used to perform reset
- */
+ *
phy-config = < 1 0 0
1 1 147
0 0 0>;
- reg = < 0x48064800 0x400 /* EHCI */
- 0x48064000 0x400 /* UHH */
- 0x48062000 0x1000 /* TLL */ >;
+ reg = < 0x48064800 0x400 /* EHCI *
+ 0x48064000 0x400 /* UHH *
+ 0x48062000 0x1000 /* TLL * >;
interrupts = < 77 >;
interrupt-parent = <&AINTC>;
};
-
+*/
};
chosen {
More information about the svn-soc-all
mailing list