18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#include <linux/init.h> 98c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 108c2ecf20Sopenharmony_ci#include <linux/serial_8250.h> 118c2ecf20Sopenharmony_ci#include <linux/rtc/ds1685.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <asm/ip32/mace.h> 148c2ecf20Sopenharmony_ci#include <asm/ip32/ip32_ints.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciextern void ip32_prepare_poweroff(void); 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define MACEISA_SERIAL1_OFFS offsetof(struct sgi_mace, isa.serial1) 198c2ecf20Sopenharmony_ci#define MACEISA_SERIAL2_OFFS offsetof(struct sgi_mace, isa.serial2) 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define MACE_PORT(offset,_irq) \ 228c2ecf20Sopenharmony_ci{ \ 238c2ecf20Sopenharmony_ci .mapbase = MACE_BASE + offset, \ 248c2ecf20Sopenharmony_ci .irq = _irq, \ 258c2ecf20Sopenharmony_ci .uartclk = 1843200, \ 268c2ecf20Sopenharmony_ci .iotype = UPIO_MEM, \ 278c2ecf20Sopenharmony_ci .flags = UPF_SKIP_TEST|UPF_IOREMAP, \ 288c2ecf20Sopenharmony_ci .regshift = 8, \ 298c2ecf20Sopenharmony_ci} 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cistatic struct plat_serial8250_port uart8250_data[] = { 328c2ecf20Sopenharmony_ci MACE_PORT(MACEISA_SERIAL1_OFFS, MACEISA_SERIAL1_IRQ), 338c2ecf20Sopenharmony_ci MACE_PORT(MACEISA_SERIAL2_OFFS, MACEISA_SERIAL2_IRQ), 348c2ecf20Sopenharmony_ci { }, 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic struct platform_device uart8250_device = { 388c2ecf20Sopenharmony_ci .name = "serial8250", 398c2ecf20Sopenharmony_ci .id = PLAT8250_DEV_PLATFORM, 408c2ecf20Sopenharmony_ci .dev = { 418c2ecf20Sopenharmony_ci .platform_data = uart8250_data, 428c2ecf20Sopenharmony_ci }, 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic int __init uart8250_init(void) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci return platform_device_register(&uart8250_device); 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cidevice_initcall(uart8250_init); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic __init int meth_devinit(void) 538c2ecf20Sopenharmony_ci{ 548c2ecf20Sopenharmony_ci struct platform_device *pd; 558c2ecf20Sopenharmony_ci int ret; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci pd = platform_device_alloc("meth", -1); 588c2ecf20Sopenharmony_ci if (!pd) 598c2ecf20Sopenharmony_ci return -ENOMEM; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci ret = platform_device_add(pd); 628c2ecf20Sopenharmony_ci if (ret) 638c2ecf20Sopenharmony_ci platform_device_put(pd); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci return ret; 668c2ecf20Sopenharmony_ci} 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cidevice_initcall(meth_devinit); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic __init int sgio2audio_devinit(void) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci struct platform_device *pd; 738c2ecf20Sopenharmony_ci int ret; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci pd = platform_device_alloc("sgio2audio", -1); 768c2ecf20Sopenharmony_ci if (!pd) 778c2ecf20Sopenharmony_ci return -ENOMEM; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci ret = platform_device_add(pd); 808c2ecf20Sopenharmony_ci if (ret) 818c2ecf20Sopenharmony_ci platform_device_put(pd); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci return ret; 848c2ecf20Sopenharmony_ci} 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cidevice_initcall(sgio2audio_devinit); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistatic __init int sgio2btns_devinit(void) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0)); 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cidevice_initcall(sgio2btns_devinit); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define MACE_RTC_RES_START (MACE_BASE + offsetof(struct sgi_mace, isa.rtc)) 968c2ecf20Sopenharmony_ci#define MACE_RTC_RES_END (MACE_RTC_RES_START + 32767) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic struct resource ip32_rtc_resources[] = { 998c2ecf20Sopenharmony_ci { 1008c2ecf20Sopenharmony_ci .start = MACEISA_RTC_IRQ, 1018c2ecf20Sopenharmony_ci .end = MACEISA_RTC_IRQ, 1028c2ecf20Sopenharmony_ci .flags = IORESOURCE_IRQ 1038c2ecf20Sopenharmony_ci }, { 1048c2ecf20Sopenharmony_ci .start = MACE_RTC_RES_START, 1058c2ecf20Sopenharmony_ci .end = MACE_RTC_RES_END, 1068c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 1078c2ecf20Sopenharmony_ci } 1088c2ecf20Sopenharmony_ci}; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* RTC registers on IP32 are each padded by 256 bytes (0x100). */ 1118c2ecf20Sopenharmony_cistatic struct ds1685_rtc_platform_data 1128c2ecf20Sopenharmony_ciip32_rtc_platform_data[] = { 1138c2ecf20Sopenharmony_ci { 1148c2ecf20Sopenharmony_ci .regstep = 0x100, 1158c2ecf20Sopenharmony_ci .bcd_mode = true, 1168c2ecf20Sopenharmony_ci .no_irq = false, 1178c2ecf20Sopenharmony_ci .uie_unsupported = false, 1188c2ecf20Sopenharmony_ci .access_type = ds1685_reg_direct, 1198c2ecf20Sopenharmony_ci .plat_prepare_poweroff = ip32_prepare_poweroff, 1208c2ecf20Sopenharmony_ci }, 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistruct platform_device ip32_rtc_device = { 1248c2ecf20Sopenharmony_ci .name = "rtc-ds1685", 1258c2ecf20Sopenharmony_ci .id = -1, 1268c2ecf20Sopenharmony_ci .dev = { 1278c2ecf20Sopenharmony_ci .platform_data = ip32_rtc_platform_data, 1288c2ecf20Sopenharmony_ci }, 1298c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(ip32_rtc_resources), 1308c2ecf20Sopenharmony_ci .resource = ip32_rtc_resources, 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_cistatic __init int sgio2_rtc_devinit(void) 1348c2ecf20Sopenharmony_ci{ 1358c2ecf20Sopenharmony_ci return platform_device_register(&ip32_rtc_device); 1368c2ecf20Sopenharmony_ci} 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cidevice_initcall(sgio2_rtc_devinit); 139