Commit 4ea29f749d564da84f624f3f0c8620c02a183d01
1 parent
1f163b14
Tosa: dummy lcd support (Dmitry Baryshkov).
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5616 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
84 additions
and
0 deletions
hw/tosa.c
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | #include "pcmcia.h" | 17 | #include "pcmcia.h" |
| 18 | #include "block.h" | 18 | #include "block.h" |
| 19 | #include "boards.h" | 19 | #include "boards.h" |
| 20 | +#include "i2c.h" | ||
| 20 | 21 | ||
| 21 | #define TOSA_RAM 0x04000000 | 22 | #define TOSA_RAM 0x04000000 |
| 22 | #define TOSA_ROM 0x00800000 | 23 | #define TOSA_ROM 0x00800000 |
| @@ -39,6 +40,10 @@ | @@ -39,6 +40,10 @@ | ||
| 39 | #define TOSA_GPIO_CHRG_ERR_LED (TOSA_SCOOP_JC_GPIO_BASE + 2) | 40 | #define TOSA_GPIO_CHRG_ERR_LED (TOSA_SCOOP_JC_GPIO_BASE + 2) |
| 40 | #define TOSA_GPIO_WLAN_LED (TOSA_SCOOP_JC_GPIO_BASE + 7) | 41 | #define TOSA_GPIO_WLAN_LED (TOSA_SCOOP_JC_GPIO_BASE + 7) |
| 41 | 42 | ||
| 43 | +#define DAC_BASE 0x4e | ||
| 44 | +#define DAC_CH1 0 | ||
| 45 | +#define DAC_CH2 1 | ||
| 46 | + | ||
| 42 | static void tosa_microdrive_attach(struct pxa2xx_state_s *cpu) | 47 | static void tosa_microdrive_attach(struct pxa2xx_state_s *cpu) |
| 43 | { | 48 | { |
| 44 | struct pcmcia_card_s *md; | 49 | struct pcmcia_card_s *md; |
| @@ -105,6 +110,83 @@ static void tosa_gpio_setup(struct pxa2xx_state_s *cpu, | @@ -105,6 +110,83 @@ static void tosa_gpio_setup(struct pxa2xx_state_s *cpu, | ||
| 105 | scoop_gpio_out_set(scp1, TOSA_GPIO_WLAN_LED, outsignals[3]); | 110 | scoop_gpio_out_set(scp1, TOSA_GPIO_WLAN_LED, outsignals[3]); |
| 106 | } | 111 | } |
| 107 | 112 | ||
| 113 | +static uint32_t tosa_ssp_read(void *opaque) | ||
| 114 | +{ | ||
| 115 | + return 0; | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +static void tosa_ssp_write(void *opaque, uint32_t value) | ||
| 119 | +{ | ||
| 120 | + fprintf(stderr, "TG: %d %02x\n", value >> 5, value & 0x1f); | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +struct tosa_dac_i2c { | ||
| 124 | + i2c_slave i2c; | ||
| 125 | + int len; | ||
| 126 | + char buf[3]; | ||
| 127 | +}; | ||
| 128 | + | ||
| 129 | +static int tosa_dac_send(i2c_slave *i2c, uint8_t data) | ||
| 130 | +{ | ||
| 131 | + struct tosa_dac_i2c *s = (struct tosa_dac_i2c *)i2c; | ||
| 132 | + s->buf[s->len] = data; | ||
| 133 | + if (s->len ++ > 2) { | ||
| 134 | +#ifdef VERBOSE | ||
| 135 | + fprintf(stderr, "%s: message too long (%i bytes)\n", __FUNCTION__, s->len); | ||
| 136 | +#endif | ||
| 137 | + return 1; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + if (s->len == 2) { | ||
| 141 | + fprintf(stderr, "dac: channel %d value 0x%02x\n", | ||
| 142 | + s->buf[0], s->buf[1]); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + return 0; | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +static void tosa_dac_event(i2c_slave *i2c, enum i2c_event event) | ||
| 149 | +{ | ||
| 150 | + struct tosa_dac_i2c *s = (struct tosa_dac_i2c *)i2c; | ||
| 151 | + s->len = 0; | ||
| 152 | + switch (event) { | ||
| 153 | + case I2C_START_SEND: | ||
| 154 | + break; | ||
| 155 | + case I2C_START_RECV: | ||
| 156 | + printf("%s: recv not supported!!!\n", __FUNCTION__); | ||
| 157 | + break; | ||
| 158 | + case I2C_FINISH: | ||
| 159 | +#ifdef VERBOSE | ||
| 160 | + if (s->len < 2) | ||
| 161 | + printf("%s: message too short (%i bytes)\n", __FUNCTION__, s->len); | ||
| 162 | + if (s->len > 2) | ||
| 163 | + printf("%s: message too long\n", __FUNCTION__); | ||
| 164 | +#endif | ||
| 165 | + break; | ||
| 166 | + default: | ||
| 167 | + break; | ||
| 168 | + } | ||
| 169 | +} | ||
| 170 | + | ||
| 171 | +int tosa_dac_recv(i2c_slave *s) | ||
| 172 | +{ | ||
| 173 | + printf("%s: recv not supported!!!\n", __FUNCTION__); | ||
| 174 | + return -1; | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | +static void tosa_tg_init(struct pxa2xx_state_s *cpu) | ||
| 178 | +{ | ||
| 179 | + struct i2c_bus *bus = pxa2xx_i2c_bus(cpu->i2c[0]); | ||
| 180 | + struct i2c_slave *dac = i2c_slave_init(bus, 0, sizeof(struct tosa_dac_i2c)); | ||
| 181 | + dac->send = tosa_dac_send; | ||
| 182 | + dac->event = tosa_dac_event; | ||
| 183 | + dac->recv = tosa_dac_recv; | ||
| 184 | + i2c_set_slave_address(dac, DAC_BASE); | ||
| 185 | + pxa2xx_ssp_attach(cpu->ssp[1], tosa_ssp_read, | ||
| 186 | + tosa_ssp_write, cpu); | ||
| 187 | +} | ||
| 188 | + | ||
| 189 | + | ||
| 108 | static struct arm_boot_info tosa_binfo = { | 190 | static struct arm_boot_info tosa_binfo = { |
| 109 | .loader_start = PXA2XX_SDRAM_BASE, | 191 | .loader_start = PXA2XX_SDRAM_BASE, |
| 110 | .ram_size = 0x04000000, | 192 | .ram_size = 0x04000000, |
| @@ -141,6 +223,8 @@ static void tosa_init(ram_addr_t ram_size, int vga_ram_size, | @@ -141,6 +223,8 @@ static void tosa_init(ram_addr_t ram_size, int vga_ram_size, | ||
| 141 | 223 | ||
| 142 | tosa_microdrive_attach(cpu); | 224 | tosa_microdrive_attach(cpu); |
| 143 | 225 | ||
| 226 | + tosa_tg_init(cpu); | ||
| 227 | + | ||
| 144 | /* Setup initial (reset) machine state */ | 228 | /* Setup initial (reset) machine state */ |
| 145 | cpu->env->regs[15] = tosa_binfo.loader_start; | 229 | cpu->env->regs[15] = tosa_binfo.loader_start; |
| 146 | 230 |