Lines Matching refs:micro

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
83 dev_dbg(micro->dev, "RX msg: %02x, %d bytes\n", id, len); in micro_rx_msg()
85 spin_lock(&micro->lock); in micro_rx_msg()
95 if (micro->msg && micro->msg->id == id) { in micro_rx_msg()
96 struct ipaq_micro_msg *msg = micro->msg; in micro_rx_msg()
100 complete(&micro->msg->ack); in micro_rx_msg()
101 if (!list_empty(&micro->queue)) { in micro_rx_msg()
102 micro->msg = list_entry(micro->queue.next, in micro_rx_msg()
105 list_del_init(&micro->msg->node); in micro_rx_msg()
106 ipaq_micro_trigger_tx(micro); in micro_rx_msg()
108 micro->msg = NULL; in micro_rx_msg()
109 dev_dbg(micro->dev, "OK RX message 0x%02x\n", id); in micro_rx_msg()
111 dev_err(micro->dev, in micro_rx_msg()
113 if (!micro->msg) in micro_rx_msg()
114 dev_info(micro->dev, "no message queued\n"); in micro_rx_msg()
116 dev_info(micro->dev, "expected message %02x\n", in micro_rx_msg()
117 micro->msg->id); in micro_rx_msg()
121 if (micro->key) in micro_rx_msg()
122 micro->key(micro->key_data, len, data); in micro_rx_msg()
124 dev_dbg(micro->dev, "key message ignored, no handle\n"); in micro_rx_msg()
127 if (micro->ts) in micro_rx_msg()
128 micro->ts(micro->ts_data, len, data); in micro_rx_msg()
130 dev_dbg(micro->dev, "touchscreen message ignored, no handle\n"); in micro_rx_msg()
133 dev_err(micro->dev, in micro_rx_msg()
139 spin_unlock(&micro->lock); in micro_rx_msg()
142 static void micro_process_char(struct ipaq_micro *micro, u8 ch) in micro_process_char() argument
144 struct ipaq_micro_rxdev *rx = &micro->rx; in micro_process_char()
166 micro_rx_msg(micro, rx->id, rx->len, rx->buf); in micro_process_char()
172 static void micro_rx_chars(struct ipaq_micro *micro) in micro_rx_chars() argument
176 while ((status = readl(micro->base + UTSR1)) & UTSR1_RNE) { in micro_rx_chars()
177 ch = readl(micro->base + UTDR); in micro_rx_chars()
179 dev_err(micro->dev, "rx: parity error\n"); in micro_rx_chars()
181 dev_err(micro->dev, "rx: framing error\n"); in micro_rx_chars()
183 dev_err(micro->dev, "rx: overrun error\n"); in micro_rx_chars()
184 micro_process_char(micro, ch); in micro_rx_chars()
188 static void ipaq_micro_get_version(struct ipaq_micro *micro) in ipaq_micro_get_version() argument
194 ipaq_micro_tx_msg_sync(micro, &msg); in ipaq_micro_get_version()
196 memcpy(micro->version, msg.rx_data, 4); in ipaq_micro_get_version()
197 micro->version[4] = '\0'; in ipaq_micro_get_version()
199 memcpy(micro->version, msg.rx_data, 4); in ipaq_micro_get_version()
200 micro->version[4] = '\0'; in ipaq_micro_get_version()
203 dev_err(micro->dev, in ipaq_micro_get_version()
208 static void ipaq_micro_eeprom_read(struct ipaq_micro *micro, in ipaq_micro_eeprom_read() argument
220 ipaq_micro_tx_msg_sync(micro, &msg); in ipaq_micro_eeprom_read()
240 static void __init ipaq_micro_eeprom_dump(struct ipaq_micro *micro) in ipaq_micro_eeprom_dump() argument
245 ipaq_micro_eeprom_read(micro, 0, 128, dump); in ipaq_micro_eeprom_dump()
248 dev_info(micro->dev, "HW version %s\n", str); in ipaq_micro_eeprom_dump()
253 dev_info(micro->dev, "serial number: %s\n", str); in ipaq_micro_eeprom_dump()
260 dev_info(micro->dev, "module ID: %s\n", str); in ipaq_micro_eeprom_dump()
265 dev_info(micro->dev, "product revision: %s\n", str); in ipaq_micro_eeprom_dump()
268 dev_info(micro->dev, "product ID: %u\n", ipaq_micro_to_u16(dump+80)); in ipaq_micro_eeprom_dump()
269 dev_info(micro->dev, "frame rate: %u fps\n", in ipaq_micro_eeprom_dump()
271 dev_info(micro->dev, "page mode: %u\n", ipaq_micro_to_u16(dump+84)); in ipaq_micro_eeprom_dump()
272 dev_info(micro->dev, "country ID: %u\n", ipaq_micro_to_u16(dump+86)); in ipaq_micro_eeprom_dump()
273 dev_info(micro->dev, "color display: %s\n", in ipaq_micro_eeprom_dump()
275 dev_info(micro->dev, "ROM size: %u MiB\n", ipaq_micro_to_u16(dump+90)); in ipaq_micro_eeprom_dump()
276 dev_info(micro->dev, "RAM size: %u KiB\n", ipaq_micro_to_u16(dump+92)); in ipaq_micro_eeprom_dump()
277 dev_info(micro->dev, "screen: %u x %u\n", in ipaq_micro_eeprom_dump()
281 static void micro_tx_chars(struct ipaq_micro *micro) in micro_tx_chars() argument
283 struct ipaq_micro_txdev *tx = &micro->tx; in micro_tx_chars()
287 (readl(micro->base + UTSR1) & UTSR1_TNF)) { in micro_tx_chars()
288 writel(tx->buf[tx->index], micro->base + UTDR); in micro_tx_chars()
293 val = readl(micro->base + UTCR3); in micro_tx_chars()
295 writel(val, micro->base + UTCR3); in micro_tx_chars()
298 static void micro_reset_comm(struct ipaq_micro *micro) in micro_reset_comm() argument
300 struct ipaq_micro_rxdev *rx = &micro->rx; in micro_reset_comm()
303 if (micro->msg) in micro_reset_comm()
304 complete(&micro->msg->ack); in micro_reset_comm()
310 writel(0x01, micro->sdlc + 0x0); /* Select UART mode */ in micro_reset_comm()
313 writel(0x0, micro->base + UTCR3); in micro_reset_comm()
316 writel(UTCR0_8BitData | UTCR0_1StpBit, micro->base + UTCR0); in micro_reset_comm()
319 writel(0x0, micro->base + UTCR1); in micro_reset_comm()
320 writel(0x1, micro->base + UTCR2); in micro_reset_comm()
323 writel(0xff, micro->base + UTSR0); in micro_reset_comm()
326 writel(UTCR3_TXE | UTCR3_RXE | UTCR3_RIE, micro->base + UTCR3); in micro_reset_comm()
327 val = readl(micro->base + UTCR3); in micro_reset_comm()
329 writel(val, micro->base + UTCR3); in micro_reset_comm()
334 struct ipaq_micro *micro = dev_id; in micro_serial_isr() local
335 struct ipaq_micro_txdev *tx = &micro->tx; in micro_serial_isr()
338 status = readl(micro->base + UTSR0); in micro_serial_isr()
343 writel(UTSR0_RID, micro->base + UTSR0); in micro_serial_isr()
344 micro_rx_chars(micro); in micro_serial_isr()
350 micro->base + UTSR0); in micro_serial_isr()
353 micro_tx_chars(micro); in micro_serial_isr()
355 status = readl(micro->base + UTSR0); in micro_serial_isr()
373 struct ipaq_micro *micro = dev_get_drvdata(dev); in micro_resume() local
375 micro_reset_comm(micro); in micro_resume()
383 struct ipaq_micro *micro; in micro_probe() local
388 micro = devm_kzalloc(&pdev->dev, sizeof(*micro), GFP_KERNEL); in micro_probe()
389 if (!micro) in micro_probe()
392 micro->dev = &pdev->dev; in micro_probe()
395 micro->base = devm_ioremap_resource(&pdev->dev, res); in micro_probe()
396 if (IS_ERR(micro->base)) in micro_probe()
397 return PTR_ERR(micro->base); in micro_probe()
399 micro->sdlc = devm_platform_ioremap_resource(pdev, 1); in micro_probe()
400 if (IS_ERR(micro->sdlc)) in micro_probe()
401 return PTR_ERR(micro->sdlc); in micro_probe()
403 micro_reset_comm(micro); in micro_probe()
410 micro); in micro_probe()
417 spin_lock_init(&micro->lock); in micro_probe()
418 INIT_LIST_HEAD(&micro->queue); in micro_probe()
419 platform_set_drvdata(pdev, micro); in micro_probe()
429 ipaq_micro_get_version(micro); in micro_probe()
430 dev_info(&pdev->dev, "Atmel micro ASIC version %s\n", micro->version); in micro_probe()
431 ipaq_micro_eeprom_dump(micro); in micro_probe()