socsvn commit: r240534 - soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl
aleek at FreeBSD.org
aleek at FreeBSD.org
Sun Aug 19 16:18:46 UTC 2012
Author: aleek
Date: Sun Aug 19 16:18:43 2012
New Revision: 240534
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240534
Log:
created separate function for modyfing LED pin status
Modified:
soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c
soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.h
Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Sun Aug 19 14:48:33 2012 (r240533)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.c Sun Aug 19 16:18:43 2012 (r240534)
@@ -3,6 +3,10 @@
* Ben Gray <ben.r.gray at gmail.com>.
* All rights reserved.
*
+ * Copyright (c) 2012
+ * Aleksander Dutkowski <aleek at FreeBSD.org>.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -815,6 +819,41 @@
}
/**
+ * twl_vreg_led_set - enables or disabled LEDs
+ * @sc: device soft context
+ * @leden: LEDEN register mask
+ *
+ * To enable led use simple mask TWL4030_LEDEN_LEDnON,
+ * to disable ~TWL4030_LEDEN_LEDnON
+ *
+ * LOCKING:
+ * The TWL_VEG exclusive lock must be held while this function is called.
+ *
+ * RETURNS:
+ * Zero on success otherwise EINVAL.
+ * */
+static int
+twl_vreg_led_set( struct twl_vreg_softc *sc, uint8_t led )
+{
+ uint8_t val;
+
+ if( twl_read( sc->sc_pdev, 2, TWL4030_LEDEN, &val, 1 ) != 0 )
+ {
+ device_printf( sc->sc_dev, "Could not read LEDEN register\n" );
+ return EINVAL;
+ }
+
+ val &= led;
+
+ if( twl_write( sc->sc_pdev, 2, TWL4030_LEDEN, &val, 1 ) != 0 )
+ {
+ device_printf( sc->sc_dev, "Could not write LEDEN register\n" );
+ return EINVAL;
+ }
+ return 0;
+}
+
+/**
* twl_add_regulator - adds single voltage regulator sysctls for the device
* @sc: device soft context
* @name: the name of the regulator
@@ -897,8 +936,11 @@
int len = 0, prop_len;
uint8_t val;
- /* Enable writing to power configuration registers */
if (twl_is_4030(sc->sc_pdev)) {
+ /* Enable writing to power configuration registers
+ * by writing proper values to PROTECT_KEY register
+ */
+
val = 0xC0;
if( twl_write( sc->sc_pdev, 3, 0x44, &val, 1 ) != 0 )
{
@@ -931,19 +973,11 @@
return 0;
}
- if( twl_read( sc->sc_pdev, 2, 0xEE, &val, 1 ) != 0 )
- {
- device_printf( sc->sc_dev, "Could not read LEDA register\n" );
- return 0;
- }
- val &= ~0x03;
- if( twl_write( sc->sc_pdev, 2, 0xEE, &val, 1 ) != 0 )
- {
- device_printf( sc->sc_dev, "Could not write LEDA register\n" );
- return 0;
- }
-
-
+ // if we have BeagleBoard-xM, we need to repower HUB
+ val = ~(TWL4030_LEDEN_LEDAON || TWL4030_LEDEN_LEDBON);
+ twl_vreg_led_set( sc, val );
+ val = (TWL4030_LEDEN_LEDAON || TWL4030_LEDEN_LEDBON);
+ twl_vreg_led_set( sc, val );
}
Modified: soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.h
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.h Sun Aug 19 14:48:33 2012 (r240533)
+++ soc2012/aleek/beaglexm-armv6/sys/arm/ti/twl/twl_vreg.h Sun Aug 19 16:18:43 2012 (r240534)
@@ -3,6 +3,10 @@
* Ben Gray <ben.r.gray at gmail.com>.
* All rights reserved.
*
+ * Copyright (c) 2012
+ * Aleksander Dutkowski <aleek at FreeBSD.org>.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -31,4 +35,13 @@
int twl_vreg_get_voltage(device_t dev, const char *name, int *millivolts);
int twl_vreg_set_voltage(device_t dev, const char *name, int millivolts);
+#define TWL4030_LEDEN 0xEE
+#define TWL4030_LEDEN_LEDAON 0x01
+#define TWL4030_LEDEN_LEDBON 0x02
+
+#define TWL4030_PROTECT_KEY 0x44
+#define TWL4030_PROTECT_KEY_1 0xC0
+#define TWL4030_PROTECT_KEY_2 0x0C
+
+
#endif /* _TWL_VREG_H_ */
More information about the svn-soc-all
mailing list