GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Code specific to PKUnity SoC and UniCore ISA |
| 3 | * |
| 4 | * Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn> |
| 5 | * Copyright (C) 2001-2011 Guan Xuetao |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | #ifndef _I8042_UNICORE32_H |
| 12 | #define _I8042_UNICORE32_H |
| 13 | |
| 14 | #include <mach/hardware.h> |
| 15 | |
| 16 | /* |
| 17 | * Names. |
| 18 | */ |
| 19 | #define I8042_KBD_PHYS_DESC "isa0060/serio0" |
| 20 | #define I8042_AUX_PHYS_DESC "isa0060/serio1" |
| 21 | #define I8042_MUX_PHYS_DESC "isa0060/serio%d" |
| 22 | |
| 23 | /* |
| 24 | * IRQs. |
| 25 | */ |
| 26 | #define I8042_KBD_IRQ IRQ_PS2_KBD |
| 27 | #define I8042_AUX_IRQ IRQ_PS2_AUX |
| 28 | |
| 29 | /* |
| 30 | * Register numbers. |
| 31 | */ |
GuanXuetao | e5abf78 | 2011-02-26 21:21:18 +0800 | [diff] [blame] | 32 | #define I8042_COMMAND_REG PS2_COMMAND |
| 33 | #define I8042_STATUS_REG PS2_STATUS |
| 34 | #define I8042_DATA_REG PS2_DATA |
GuanXuetao | 3838b82 | 2011-02-18 18:38:33 +0800 | [diff] [blame] | 35 | |
GuanXuetao | e5abf78 | 2011-02-26 21:21:18 +0800 | [diff] [blame] | 36 | #define I8042_REGION_START (resource_size_t)(PS2_DATA) |
GuanXuetao | 3838b82 | 2011-02-18 18:38:33 +0800 | [diff] [blame] | 37 | #define I8042_REGION_SIZE (resource_size_t)(16) |
GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 38 | |
| 39 | static inline int i8042_read_data(void) |
| 40 | { |
GuanXuetao | 3838b82 | 2011-02-18 18:38:33 +0800 | [diff] [blame] | 41 | return readb(I8042_DATA_REG); |
GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static inline int i8042_read_status(void) |
| 45 | { |
GuanXuetao | 3838b82 | 2011-02-18 18:38:33 +0800 | [diff] [blame] | 46 | return readb(I8042_STATUS_REG); |
GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static inline void i8042_write_data(int val) |
| 50 | { |
GuanXuetao | 3838b82 | 2011-02-18 18:38:33 +0800 | [diff] [blame] | 51 | writeb(val, I8042_DATA_REG); |
GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static inline void i8042_write_command(int val) |
| 55 | { |
GuanXuetao | 3838b82 | 2011-02-18 18:38:33 +0800 | [diff] [blame] | 56 | writeb(val, I8042_COMMAND_REG); |
GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static inline int i8042_platform_init(void) |
| 60 | { |
GuanXuetao | 4517366 | 2011-02-25 17:58:00 +0800 | [diff] [blame] | 61 | if (!request_mem_region(I8042_REGION_START, I8042_REGION_SIZE, "i8042")) |
GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 62 | return -EBUSY; |
| 63 | |
| 64 | i8042_reset = 1; |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | static inline void i8042_platform_exit(void) |
| 69 | { |
GuanXuetao | 4517366 | 2011-02-25 17:58:00 +0800 | [diff] [blame] | 70 | release_mem_region(I8042_REGION_START, I8042_REGION_SIZE); |
GuanXuetao | 425ad52 | 2011-01-15 18:28:19 +0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | #endif /* _I8042_UNICORE32_H */ |