1 /* Calypso DBB internal PWL (Pulse Width / Light) Driver */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #define BASE_ADDR_PWL 0xfffe8000
27 #define PWL_REG(m) (BASE_ADDR_PWL + (m))
29 #define ASIC_CONF_REG 0xfffef008
30 #define LIGHT_LEVEL_REG 0xfffe4810
37 #define ASCONF_PWL_ENA (1 << 4)
39 void bl_mode_pwl(int on)
43 reg = readw(ASIC_CONF_REG);
46 writeb(0x01, PWL_REG(PWL_CTRL));
47 /* Switch pin from LT to PWL */
48 reg |= ASCONF_PWL_ENA;
49 writew(reg, ASIC_CONF_REG);
51 /* Switch pin from PWL to LT */
52 reg |= ~ASCONF_PWL_ENA;
53 writew(reg, ASIC_CONF_REG);
54 writeb(0x00, PWL_REG(PWL_CTRL));
58 void bl_level(uint8_t level)
60 if (readw(ASIC_CONF_REG) & ASCONF_PWL_ENA) {
61 writeb(level, PWL_REG(PWL_LEVEL));
63 /* we need to scale the light level, as the
64 * ARMIO light controller only knows 0..63 */
65 writeb(level>>2, LIGHT_LEVEL_REG);