Lines Matching full:micro

23 #include <linux/mfd/ipaq-micro.h>
31 static void ipaq_micro_trigger_tx(struct ipaq_micro *micro) in ipaq_micro_trigger_tx() argument
33 struct ipaq_micro_txdev *tx = &micro->tx; in ipaq_micro_trigger_tx()
34 struct ipaq_micro_msg *msg = micro->msg; in ipaq_micro_trigger_tx()
55 val = readl(micro->base + UTCR3); in ipaq_micro_trigger_tx()
57 writel(val, micro->base + UTCR3); in ipaq_micro_trigger_tx()
60 int ipaq_micro_tx_msg(struct ipaq_micro *micro, struct ipaq_micro_msg *msg) in ipaq_micro_tx_msg() argument
64 dev_dbg(micro->dev, "TX msg: %02x, %d bytes\n", msg->id, msg->tx_len); in ipaq_micro_tx_msg()
66 spin_lock_irqsave(&micro->lock, flags); in ipaq_micro_tx_msg()
67 if (micro->msg) { in ipaq_micro_tx_msg()
68 list_add_tail(&msg->node, &micro->queue); in ipaq_micro_tx_msg()
69 spin_unlock_irqrestore(&micro->lock, flags); in ipaq_micro_tx_msg()
72 micro->msg = msg; in ipaq_micro_tx_msg()
73 ipaq_micro_trigger_tx(micro); in ipaq_micro_tx_msg()
74 spin_unlock_irqrestore(&micro->lock, flags); in ipaq_micro_tx_msg()
79 static void micro_rx_msg(struct ipaq_micro *micro, u8 id, int len, u8 *data) in micro_rx_msg() argument
81 dev_dbg(micro->dev, "RX msg: %02x, %d bytes\n", id, len); in micro_rx_msg()
83 spin_lock(&micro->lock); in micro_rx_msg()
93 if (micro->msg && micro->msg->id == id) { in micro_rx_msg()
94 struct ipaq_micro_msg *msg = micro->msg; in micro_rx_msg()
98 complete(&micro->msg->ack); in micro_rx_msg()
99 if (!list_empty(&micro->queue)) { in micro_rx_msg()
100 micro->msg = list_entry(micro->queue.next, in micro_rx_msg()
103 list_del_init(&micro->msg->node); in micro_rx_msg()
104 ipaq_micro_trigger_tx(micro); in micro_rx_msg()
106 micro->msg = NULL; in micro_rx_msg()
107 dev_dbg(micro->dev, "OK RX message 0x%02x\n", id); in micro_rx_msg()
109 dev_err(micro->dev, in micro_rx_msg()
111 if (!micro->msg) in micro_rx_msg()
112 dev_info(micro->dev, "no message queued\n"); in micro_rx_msg()
114 dev_info(micro->dev, "expected message %02x\n", in micro_rx_msg()
115 micro->msg->id); in micro_rx_msg()
119 if (micro->key) in micro_rx_msg()
120 micro->key(micro->key_data, len, data); in micro_rx_msg()
122 dev_dbg(micro->dev, "key message ignored, no handle\n"); in micro_rx_msg()
125 if (micro->ts) in micro_rx_msg()
126 micro->ts(micro->ts_data, len, data); in micro_rx_msg()
128 dev_dbg(micro->dev, "touchscreen message ignored, no handle\n"); in micro_rx_msg()
131 dev_err(micro->dev, in micro_rx_msg()
134 spin_unlock(&micro->lock); in micro_rx_msg()
137 static void micro_process_char(struct ipaq_micro *micro, u8 ch) in micro_process_char() argument
139 struct ipaq_micro_rxdev *rx = &micro->rx; in micro_process_char()
161 micro_rx_msg(micro, rx->id, rx->len, rx->buf); in micro_process_char()
167 static void micro_rx_chars(struct ipaq_micro *micro) in micro_rx_chars() argument
171 while ((status = readl(micro->base + UTSR1)) & UTSR1_RNE) { in micro_rx_chars()
172 ch = readl(micro->base + UTDR); in micro_rx_chars()
174 dev_err(micro->dev, "rx: parity error\n"); in micro_rx_chars()
176 dev_err(micro->dev, "rx: framing error\n"); in micro_rx_chars()
178 dev_err(micro->dev, "rx: overrun error\n"); in micro_rx_chars()
179 micro_process_char(micro, ch); in micro_rx_chars()
183 static void ipaq_micro_get_version(struct ipaq_micro *micro) in ipaq_micro_get_version() argument
189 ipaq_micro_tx_msg_sync(micro, &msg); in ipaq_micro_get_version()
191 memcpy(micro->version, msg.rx_data, 4); in ipaq_micro_get_version()
192 micro->version[4] = '\0'; in ipaq_micro_get_version()
194 memcpy(micro->version, msg.rx_data, 4); in ipaq_micro_get_version()
195 micro->version[4] = '\0'; in ipaq_micro_get_version()
198 dev_err(micro->dev, in ipaq_micro_get_version()
203 static void ipaq_micro_eeprom_read(struct ipaq_micro *micro, in ipaq_micro_eeprom_read() argument
215 ipaq_micro_tx_msg_sync(micro, &msg); in ipaq_micro_eeprom_read()
235 static void __init ipaq_micro_eeprom_dump(struct ipaq_micro *micro) in ipaq_micro_eeprom_dump() argument
240 ipaq_micro_eeprom_read(micro, 0, 128, dump); in ipaq_micro_eeprom_dump()
243 dev_info(micro->dev, "HW version %s\n", str); in ipaq_micro_eeprom_dump()
248 dev_info(micro->dev, "serial number: %s\n", str); in ipaq_micro_eeprom_dump()
255 dev_info(micro->dev, "module ID: %s\n", str); in ipaq_micro_eeprom_dump()
260 dev_info(micro->dev, "product revision: %s\n", str); in ipaq_micro_eeprom_dump()
263 dev_info(micro->dev, "product ID: %u\n", ipaq_micro_to_u16(dump+80)); in ipaq_micro_eeprom_dump()
264 dev_info(micro->dev, "frame rate: %u fps\n", in ipaq_micro_eeprom_dump()
266 dev_info(micro->dev, "page mode: %u\n", ipaq_micro_to_u16(dump+84)); in ipaq_micro_eeprom_dump()
267 dev_info(micro->dev, "country ID: %u\n", ipaq_micro_to_u16(dump+86)); in ipaq_micro_eeprom_dump()
268 dev_info(micro->dev, "color display: %s\n", in ipaq_micro_eeprom_dump()
270 dev_info(micro->dev, "ROM size: %u MiB\n", ipaq_micro_to_u16(dump+90)); in ipaq_micro_eeprom_dump()
271 dev_info(micro->dev, "RAM size: %u KiB\n", ipaq_micro_to_u16(dump+92)); in ipaq_micro_eeprom_dump()
272 dev_info(micro->dev, "screen: %u x %u\n", in ipaq_micro_eeprom_dump()
276 static void micro_tx_chars(struct ipaq_micro *micro) in micro_tx_chars() argument
278 struct ipaq_micro_txdev *tx = &micro->tx; in micro_tx_chars()
282 (readl(micro->base + UTSR1) & UTSR1_TNF)) { in micro_tx_chars()
283 writel(tx->buf[tx->index], micro->base + UTDR); in micro_tx_chars()
288 val = readl(micro->base + UTCR3); in micro_tx_chars()
290 writel(val, micro->base + UTCR3); in micro_tx_chars()
293 static void micro_reset_comm(struct ipaq_micro *micro) in micro_reset_comm() argument
295 struct ipaq_micro_rxdev *rx = &micro->rx; in micro_reset_comm()
298 if (micro->msg) in micro_reset_comm()
299 complete(&micro->msg->ack); in micro_reset_comm()
305 writel(0x01, micro->sdlc + 0x0); /* Select UART mode */ in micro_reset_comm()
308 writel(0x0, micro->base + UTCR3); in micro_reset_comm()
311 writel(UTCR0_8BitData | UTCR0_1StpBit, micro->base + UTCR0); in micro_reset_comm()
314 writel(0x0, micro->base + UTCR1); in micro_reset_comm()
315 writel(0x1, micro->base + UTCR2); in micro_reset_comm()
318 writel(0xff, micro->base + UTSR0); in micro_reset_comm()
321 writel(UTCR3_TXE | UTCR3_RXE | UTCR3_RIE, micro->base + UTCR3); in micro_reset_comm()
322 val = readl(micro->base + UTCR3); in micro_reset_comm()
324 writel(val, micro->base + UTCR3); in micro_reset_comm()
329 struct ipaq_micro *micro = dev_id; in micro_serial_isr() local
330 struct ipaq_micro_txdev *tx = &micro->tx; in micro_serial_isr()
333 status = readl(micro->base + UTSR0); in micro_serial_isr()
338 writel(UTSR0_RID, micro->base + UTSR0); in micro_serial_isr()
339 micro_rx_chars(micro); in micro_serial_isr()
345 micro->base + UTSR0); in micro_serial_isr()
348 micro_tx_chars(micro); in micro_serial_isr()
350 status = readl(micro->base + UTSR0); in micro_serial_isr()
359 { .name = "ipaq-micro-backlight", },
360 { .name = "ipaq-micro-battery", },
361 { .name = "ipaq-micro-keys", },
362 { .name = "ipaq-micro-ts", },
363 { .name = "ipaq-micro-leds", },
368 struct ipaq_micro *micro = dev_get_drvdata(dev); in micro_resume() local
370 micro_reset_comm(micro); in micro_resume()
378 struct ipaq_micro *micro; in micro_probe() local
382 micro = devm_kzalloc(&pdev->dev, sizeof(*micro), GFP_KERNEL); in micro_probe()
383 if (!micro) in micro_probe()
386 micro->dev = &pdev->dev; in micro_probe()
388 micro->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in micro_probe()
389 if (IS_ERR(micro->base)) in micro_probe()
390 return PTR_ERR(micro->base); in micro_probe()
392 micro->sdlc = devm_platform_ioremap_resource(pdev, 1); in micro_probe()
393 if (IS_ERR(micro->sdlc)) in micro_probe()
394 return PTR_ERR(micro->sdlc); in micro_probe()
396 micro_reset_comm(micro); in micro_probe()
402 IRQF_SHARED, "ipaq-micro", in micro_probe()
403 micro); in micro_probe()
410 spin_lock_init(&micro->lock); in micro_probe()
411 INIT_LIST_HEAD(&micro->queue); in micro_probe()
412 platform_set_drvdata(pdev, micro); in micro_probe()
422 ipaq_micro_get_version(micro); in micro_probe()
423 dev_info(&pdev->dev, "Atmel micro ASIC version %s\n", micro->version); in micro_probe()
424 ipaq_micro_eeprom_dump(micro); in micro_probe()
435 .name = "ipaq-h3xxx-micro",