18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci#ifndef _I8042_IO_H 38c2ecf20Sopenharmony_ci#define _I8042_IO_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci/* 78c2ecf20Sopenharmony_ci * Names. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define I8042_KBD_PHYS_DESC "isa0060/serio0" 118c2ecf20Sopenharmony_ci#define I8042_AUX_PHYS_DESC "isa0060/serio1" 128c2ecf20Sopenharmony_ci#define I8042_MUX_PHYS_DESC "isa0060/serio%d" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * IRQs. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifdef __alpha__ 198c2ecf20Sopenharmony_ci# define I8042_KBD_IRQ 1 208c2ecf20Sopenharmony_ci# define I8042_AUX_IRQ (RTC_PORT(0) == 0x170 ? 9 : 12) /* Jensen is special */ 218c2ecf20Sopenharmony_ci#elif defined(__arm__) 228c2ecf20Sopenharmony_ci/* defined in include/asm-arm/arch-xxx/irqs.h */ 238c2ecf20Sopenharmony_ci#include <asm/irq.h> 248c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC) 258c2ecf20Sopenharmony_ciextern int of_i8042_kbd_irq; 268c2ecf20Sopenharmony_ciextern int of_i8042_aux_irq; 278c2ecf20Sopenharmony_ci# define I8042_KBD_IRQ of_i8042_kbd_irq 288c2ecf20Sopenharmony_ci# define I8042_AUX_IRQ of_i8042_aux_irq 298c2ecf20Sopenharmony_ci#else 308c2ecf20Sopenharmony_ci# define I8042_KBD_IRQ 1 318c2ecf20Sopenharmony_ci# define I8042_AUX_IRQ 12 328c2ecf20Sopenharmony_ci#endif 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci * Register numbers. 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define I8042_COMMAND_REG 0x64 408c2ecf20Sopenharmony_ci#define I8042_STATUS_REG 0x64 418c2ecf20Sopenharmony_ci#define I8042_DATA_REG 0x60 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistatic inline int i8042_read_data(void) 448c2ecf20Sopenharmony_ci{ 458c2ecf20Sopenharmony_ci return inb(I8042_DATA_REG); 468c2ecf20Sopenharmony_ci} 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic inline int i8042_read_status(void) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci return inb(I8042_STATUS_REG); 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic inline void i8042_write_data(int val) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci outb(val, I8042_DATA_REG); 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic inline void i8042_write_command(int val) 598c2ecf20Sopenharmony_ci{ 608c2ecf20Sopenharmony_ci outb(val, I8042_COMMAND_REG); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistatic inline int i8042_platform_init(void) 648c2ecf20Sopenharmony_ci{ 658c2ecf20Sopenharmony_ci/* 668c2ecf20Sopenharmony_ci * On some platforms touching the i8042 data register region can do really 678c2ecf20Sopenharmony_ci * bad things. Because of this the region is always reserved on such boxes. 688c2ecf20Sopenharmony_ci */ 698c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC) 708c2ecf20Sopenharmony_ci if (check_legacy_ioport(I8042_DATA_REG)) 718c2ecf20Sopenharmony_ci return -ENODEV; 728c2ecf20Sopenharmony_ci#endif 738c2ecf20Sopenharmony_ci#if !defined(__sh__) && !defined(__alpha__) 748c2ecf20Sopenharmony_ci if (!request_region(I8042_DATA_REG, 16, "i8042")) 758c2ecf20Sopenharmony_ci return -EBUSY; 768c2ecf20Sopenharmony_ci#endif 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci i8042_reset = I8042_RESET_ALWAYS; 798c2ecf20Sopenharmony_ci return 0; 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistatic inline void i8042_platform_exit(void) 838c2ecf20Sopenharmony_ci{ 848c2ecf20Sopenharmony_ci#if !defined(__sh__) && !defined(__alpha__) 858c2ecf20Sopenharmony_ci release_region(I8042_DATA_REG, 16); 868c2ecf20Sopenharmony_ci#endif 878c2ecf20Sopenharmony_ci} 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#endif /* _I8042_IO_H */ 90