From 5a19531acb12f5afcf022e3b670cbc59254fcb03 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 21 Nov 2008 11:56:56 +0000 Subject: move-neo1973-pm-stuff-to-drivers-misc.patch Signed-off-by: Andy Green --- arch/arm/plat-s3c24xx/Kconfig | 5 - arch/arm/plat-s3c24xx/Makefile | 15 +- arch/arm/plat-s3c24xx/neo1973_memconfig.c | 181 ----------------------- arch/arm/plat-s3c24xx/neo1973_pm_host.c | 101 ------------- arch/arm/plat-s3c24xx/neo1973_pm_resume_reason.c | 147 ------------------ arch/arm/plat-s3c24xx/neo1973_version.c | 90 ----------- drivers/misc/Kconfig | 5 + drivers/misc/Makefile | 3 + drivers/misc/neo1973_pm_charging_led.c | 106 +++++++++++++ drivers/misc/neo1973_pm_host.c | 101 +++++++++++++ drivers/misc/neo1973_pm_resume_reason.c | 147 ++++++++++++++++++ drivers/misc/neo1973_pm_usbhost.c | 132 +++++++++++++++++ drivers/misc/neo1973_version.c | 90 +++++++++++ 13 files changed, 590 insertions(+), 533 deletions(-) delete mode 100644 arch/arm/plat-s3c24xx/neo1973_memconfig.c delete mode 100644 arch/arm/plat-s3c24xx/neo1973_pm_host.c delete mode 100644 arch/arm/plat-s3c24xx/neo1973_pm_resume_reason.c delete mode 100644 arch/arm/plat-s3c24xx/neo1973_version.c create mode 100644 drivers/misc/neo1973_pm_charging_led.c create mode 100644 drivers/misc/neo1973_pm_host.c create mode 100644 drivers/misc/neo1973_pm_resume_reason.c create mode 100644 drivers/misc/neo1973_pm_usbhost.c create mode 100644 drivers/misc/neo1973_version.c diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig index b0fe896440d..54b0ec4fa62 100644 --- a/arch/arm/plat-s3c24xx/Kconfig +++ b/arch/arm/plat-s3c24xx/Kconfig @@ -83,9 +83,4 @@ config MACH_SMDK help Common machine code for SMDK2410 and SMDK2440 -config MACH_NEO1973 - bool - help - Common machine code for Neo1973 hardware - endif diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile index 065b951aa3b..2fe793c9235 100644 --- a/arch/arm/plat-s3c24xx/Makefile +++ b/arch/arm/plat-s3c24xx/Makefile @@ -43,12 +43,9 @@ obj-$(CONFIG_S3C24XX_SPI_BUS1_GPG5_GPG6_GPG7) += spi-bus1-gpg5_6_7.o # machine common support obj-$(CONFIG_MACH_SMDK) += common-smdk.o -obj-$(CONFIG_MACH_NEO1973) += neo1973_version.o \ - neo1973_pm_host.o \ - neo1973_pm_gsm.o \ - neo1973_pm_gps.o \ - neo1973_pm_bt.o \ - gta02_pm_wlan.o \ - neo1973_shadow.o \ - neo1973_pm_resume_reason.o \ - neo1973_memconfig.o +obj-$(CONFIG_MACH_NEO1973) += \ + neo1973_pm_gsm.o \ + neo1973_pm_gps.o \ + neo1973_pm_bt.o \ + gta02_pm_wlan.o \ + neo1973_shadow.o diff --git a/arch/arm/plat-s3c24xx/neo1973_memconfig.c b/arch/arm/plat-s3c24xx/neo1973_memconfig.c deleted file mode 100644 index 6f623f179f3..00000000000 --- a/arch/arm/plat-s3c24xx/neo1973_memconfig.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Memory access timing control sysfs for the s3c24xx based device - * - * (C) 2008 by Openmoko Inc. - * Author: Andy Green - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation - * - */ - -#include -#include -#include -#include - -#include -#include -#include - -static ssize_t neo1973_memconfig_read(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int index = attr->attr.name[strlen(attr->attr.name) - 1] - '0'; - u32 reg = *((u32 *)(S3C2410_MEMREG(((index + 1) << 2)))); - static const char *meaning[][8] = { - { - [0] = "normal (1 data)", - [1] = "4 data", - [2] = "8 data", - [3] = "16 data", - }, { - [0] = "2 clocks", - [1] = "3 clocks", - [2] = "4 clocks", - [3] = "6 clocks", - }, { - [0] = "0 clocks", - [1] = "1 clock", - [2] = "2 clocks", - [3] = "4 clocks", - }, { - [0] = "1 clock", - [1] = "2 clocks", - [2] = "3 clocks", - [3] = "4 clocks", - [4] = "6 clocks", - [5] = "8 clocks", - [6] = "10 clocks", - [7] = "14 clocks", - }, { /* after this, only for CS6 and CS7 */ - [0] = "ROM / SRAM", - [1] = "(illegal)", - [2] = "(illegal)", - [3] = "Sync DRAM", - }, { - [0] = "8 Column bits", - [1] = "9 Column bits", - [2] = "10 Column bits", - [3] = "(illegal)", - }, { - [0] = "2 clocks", - [1] = "3 clocks", - [2] = "4 clocks", - [3] = "(illegal)", - } - }; - - if (index >= 6) - if (((reg >> 15) & 3) == 3) /* DRAM */ - return sprintf(buf, "BANKCON%d = 0x%08X\n DRAM:\n" - " Trcd = %s\n SCAN = %s\n", index, - reg, meaning[5][reg & 3], - meaning[1][(reg >> 2) & 3]); - - return sprintf(buf, "BANKCON%d = 0x%08X\n Type = %s\n PMC = %s\n" - " Tacp = %s\n Tcah = %s\n Tcoh = %s\n Tacc = %s\n" - " Tcos = %s\n Tacs = %s\n", - index, reg, meaning[4][(reg >> 15) & 3], - meaning[0][reg & 3], - meaning[1][(reg >> 2) & 3], - meaning[2][(reg >> 4) & 3], - meaning[2][(reg >> 6) & 3], - meaning[3][(reg >> 8) & 7], - meaning[2][(reg >> 11) & 3], - meaning[2][(reg >> 13) & 3]); -} - -static ssize_t neo1973_memconfig_write(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - int index = attr->attr.name[strlen(attr->attr.name) - 1] - '0'; - unsigned long val = simple_strtoul(buf, NULL, 16); - - dev_info(dev, "setting BANKCON%d <- 0x%08X\n", index, (u32)val); - - *((u32 *)(S3C2410_MEMREG(((index + 1) << 2)))) = (u32)val; - - return count; -} - - -static DEVICE_ATTR(BANKCON0, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); -static DEVICE_ATTR(BANKCON1, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); -static DEVICE_ATTR(BANKCON2, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); -static DEVICE_ATTR(BANKCON3, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); -static DEVICE_ATTR(BANKCON4, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); -static DEVICE_ATTR(BANKCON5, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); -static DEVICE_ATTR(BANKCON6, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); -static DEVICE_ATTR(BANKCON7, 0644, neo1973_memconfig_read, - neo1973_memconfig_write); - -static struct attribute *neo1973_memconfig_sysfs_entries[] = { - &dev_attr_BANKCON0.attr, - &dev_attr_BANKCON1.attr, - &dev_attr_BANKCON2.attr, - &dev_attr_BANKCON3.attr, - &dev_attr_BANKCON4.attr, - &dev_attr_BANKCON5.attr, - &dev_attr_BANKCON6.attr, - &dev_attr_BANKCON7.attr, - NULL -}; - -static struct attribute_group neo1973_memconfig_attr_group = { - .name = NULL, - .attrs = neo1973_memconfig_sysfs_entries, -}; - -static int __init neo1973_memconfig_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "starting\n"); - - if (machine_is_neo1973_gta01()) { - return -EINVAL; - } - - return sysfs_create_group(&pdev->dev.kobj, - &neo1973_memconfig_attr_group); -} - -static int neo1973_memconfig_remove(struct platform_device *pdev) -{ - sysfs_remove_group(&pdev->dev.kobj, &neo1973_memconfig_attr_group); - return 0; -} - -static struct platform_driver neo1973_memconfig_driver = { - .probe = neo1973_memconfig_probe, - .remove = neo1973_memconfig_remove, - .driver = { - .name = "neo1973-memconfig", - }, -}; - -static int __devinit neo1973_memconfig_init(void) -{ - return platform_driver_register(&neo1973_memconfig_driver); -} - -static void neo1973_memconfig_exit(void) -{ - platform_driver_unregister(&neo1973_memconfig_driver); -} - -module_init(neo1973_memconfig_init); -module_exit(neo1973_memconfig_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Andy Green "); -MODULE_DESCRIPTION("neo1973 memconfig"); - diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_host.c b/arch/arm/plat-s3c24xx/neo1973_pm_host.c deleted file mode 100644 index caa302eeb91..00000000000 --- a/arch/arm/plat-s3c24xx/neo1973_pm_host.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Bluetooth PM code for the FIC Neo1973 GSM Phone - * - * (C) 2007 by Openmoko Inc. - * Author: Harald Welte - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation - * - */ - -#include -#include -#include -#include - -#include -#include - -#ifdef CONFIG_MACH_NEO1973_GTA02 -#include -#include - -static ssize_t pm_host_read(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%d\n", - pcf50633_gpio_get(gta02_pcf_pdata.pcf, PCF50633_GPO)); -} - -static ssize_t pm_host_write(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - unsigned long on = simple_strtoul(buf, NULL, 10); - - pcf50633_gpio_set(gta02_pcf_pdata.pcf, PCF50633_GPO, on); - - return count; -} - -static DEVICE_ATTR(hostmode, 0644, pm_host_read, pm_host_write); - -static struct attribute *neo1973_pm_host_sysfs_entries[] = { - &dev_attr_hostmode.attr, - NULL -}; - -static struct attribute_group neo1973_pm_host_attr_group = { - .name = NULL, - .attrs = neo1973_pm_host_sysfs_entries, -}; - -static int __init neo1973_pm_host_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "starting\n"); - - switch (machine_arch_type) { -#ifdef CONFIG_MACH_NEO1973_GTA01 - case MACH_TYPE_NEO1973_GTA01: - return -EINVAL; -#endif /* CONFIG_MACH_NEO1973_GTA01 */ - default: - break; - } - - return sysfs_create_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group); -} - -static int neo1973_pm_host_remove(struct platform_device *pdev) -{ - sysfs_remove_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group); - return 0; -} - -static struct platform_driver neo1973_pm_host_driver = { - .probe = neo1973_pm_host_probe, - .remove = neo1973_pm_host_remove, - .driver = { - .name = "neo1973-pm-host", - }, -}; - -static int __devinit neo1973_pm_host_init(void) -{ - return platform_driver_register(&neo1973_pm_host_driver); -} - -static void neo1973_pm_host_exit(void) -{ - platform_driver_unregister(&neo1973_pm_host_driver); -} - -module_init(neo1973_pm_host_init); -module_exit(neo1973_pm_host_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Andy Green "); -MODULE_DESCRIPTION("Neo1973 USB Host Power Management"); -#endif diff --git a/arch/arm/plat-s3c24xx/neo1973_pm_resume_reason.c b/arch/arm/plat-s3c24xx/neo1973_pm_resume_reason.c deleted file mode 100644 index 62984a50a0a..00000000000 --- a/arch/arm/plat-s3c24xx/neo1973_pm_resume_reason.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Resume reason sysfs for the FIC Neo1973 GSM Phone - * - * (C) 2008 by Openmoko Inc. - * Author: Andy Green - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License resume_reason 2 as - * published by the Free Software Foundation - * - */ - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef CONFIG_MACH_NEO1973_GTA02 -#include -#include -#endif - -static unsigned int *gstatus4_mapped; -static char *resume_reasons[][17] = { { /* GTA01 */ - "EINT00_NULL", - "EINT01_GSM", - "EINT02_NULL", - "EINT03_NULL", - "EINT04_JACK", - "EINT05_SDCARD", - "EINT06_AUXKEY", - "EINT07_HOLDKEY", - "EINT08_NULL", - "EINT09_NULL", - "EINT10_NULL", - "EINT11_NULL", - "EINT12_NULL", - "EINT13_NULL", - "EINT14_NULL", - "EINT15_NULL", - NULL -}, { /* GTA02 */ - "EINT00_ACCEL1", - "EINT01_GSM", - "EINT02_BLUETOOTH", - "EINT03_DEBUGBRD", - "EINT04_JACK", - "EINT05_WLAN", - "EINT06_AUXKEY", - "EINT07_HOLDKEY", - "EINT08_ACCEL2", - "EINT09_PMU", - "EINT10_NULL", - "EINT11_NULL", - "EINT12_GLAMO", - "EINT13_NULL", - "EINT14_NULL", - "EINT15_NULL", - NULL -} }; - -static ssize_t resume_reason_read(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int bit = 0; - char *end = buf; - int gta = !!machine_is_neo1973_gta02(); - - for (bit = 0; resume_reasons[gta][bit]; bit++) { - if ((*gstatus4_mapped) & (1 << bit)) - end += sprintf(end, "* %s\n", resume_reasons[gta][bit]); - else - end += sprintf(end, " %s\n", resume_reasons[gta][bit]); - -#ifdef CONFIG_MACH_NEO1973_GTA02 - if ((gta) && (bit == 9)); /* PMU */ -// end += pcf50633_report_resumers(gta02_pcf_pdata.pcf, end); -#endif - } - - return end - buf; -} - - -static DEVICE_ATTR(resume_reason, 0644, resume_reason_read, NULL); - -static struct attribute *neo1973_resume_reason_sysfs_entries[] = { - &dev_attr_resume_reason.attr, - NULL -}; - -static struct attribute_group neo1973_resume_reason_attr_group = { - .name = NULL, - .attrs = neo1973_resume_reason_sysfs_entries, -}; - -static int __init neo1973_resume_reason_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "starting\n"); - - gstatus4_mapped = ioremap(0x560000BC /* GSTATUS4 */, 0x4); - if (!gstatus4_mapped) { - dev_err(&pdev->dev, "failed to ioremap() memory region\n"); - return -EINVAL; - } - - return sysfs_create_group(&pdev->dev.kobj, - &neo1973_resume_reason_attr_group); -} - -static int neo1973_resume_reason_remove(struct platform_device *pdev) -{ - sysfs_remove_group(&pdev->dev.kobj, &neo1973_resume_reason_attr_group); - iounmap(gstatus4_mapped); - return 0; -} - -static struct platform_driver neo1973_resume_reason_driver = { - .probe = neo1973_resume_reason_probe, - .remove = neo1973_resume_reason_remove, - .driver = { - .name = "neo1973-resume", - }, -}; - -static int __devinit neo1973_resume_reason_init(void) -{ - return platform_driver_register(&neo1973_resume_reason_driver); -} - -static void neo1973_resume_reason_exit(void) -{ - platform_driver_unregister(&neo1973_resume_reason_driver); -} - -module_init(neo1973_resume_reason_init); -module_exit(neo1973_resume_reason_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Andy Green "); -MODULE_DESCRIPTION("Neo1973 resume_reason"); diff --git a/arch/arm/plat-s3c24xx/neo1973_version.c b/arch/arm/plat-s3c24xx/neo1973_version.c deleted file mode 100644 index a88172132dc..00000000000 --- a/arch/arm/plat-s3c24xx/neo1973_version.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * PCB version sysfs for the FIC Neo1973 GSM Phone - * - * (C) 2007 by Openmoko Inc. - * Author: Andy Green - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation - * - */ - -#include -#include -#include -#include - -#include -#include - -#ifdef CONFIG_MACH_NEO1973_GTA02 -#include - -static ssize_t version_read(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "0x%03X\n", gta02_get_pcb_revision()); -} - - -static DEVICE_ATTR(pcb, 0644, version_read, NULL); - -static struct attribute *neo1973_version_sysfs_entries[] = { - &dev_attr_pcb.attr, - NULL -}; - -static struct attribute_group neo1973_version_attr_group = { - .name = NULL, - .attrs = neo1973_version_sysfs_entries, -}; - -static int __init neo1973_version_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "starting\n"); - - switch (machine_arch_type) { -#ifdef CONFIG_MACH_NEO1973_GTA01 - case MACH_TYPE_NEO1973_GTA01: - return -EINVAL; -#endif /* CONFIG_MACH_NEO1973_GTA01 */ - default: - break; - } - - return sysfs_create_group(&pdev->dev.kobj, &neo1973_version_attr_group); -} - -static int neo1973_version_remove(struct platform_device *pdev) -{ - sysfs_remove_group(&pdev->dev.kobj, &neo1973_version_attr_group); - return 0; -} - -static struct platform_driver neo1973_version_driver = { - .probe = neo1973_version_probe, - .remove = neo1973_version_remove, - .driver = { - .name = "neo1973-version", - }, -}; - -static int __devinit neo1973_version_init(void) -{ - return platform_driver_register(&neo1973_version_driver); -} - -static void neo1973_version_exit(void) -{ - platform_driver_unregister(&neo1973_version_driver); -} - -module_init(neo1973_version_init); -module_exit(neo1973_version_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Andy Green "); -MODULE_DESCRIPTION("Neo1973 PCB version"); -#endif diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index e07ea1cec56..50d413c816c 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -493,4 +493,9 @@ config SGI_GRU_DEBUG This option enables addition debugging code for the SGI GRU driver. If you are unsure, say N. +config MACH_NEO1973 + bool + help + Common machine code for Openmoko GTAxx hardware + endif # MISC_DEVICES diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 8455289665b..90ce0252aaa 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -32,3 +32,6 @@ obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ obj-$(CONFIG_HP_ILO) += hpilo.o obj-$(CONFIG_LOW_MEMORY_KILLER) += lowmemorykiller.o +obj-$(CONFIG_MACH_NEO1973) += neo1973_version.o \ + neo1973_pm_host.o \ + neo1973_pm_resume_reason.o diff --git a/drivers/misc/neo1973_pm_charging_led.c b/drivers/misc/neo1973_pm_charging_led.c new file mode 100644 index 00000000000..9e104a56189 --- /dev/null +++ b/drivers/misc/neo1973_pm_charging_led.c @@ -0,0 +1,106 @@ +/* + * Charging LED sysfs for the FIC Neo1973 GSM Phone + * (currently only implemented in GTA02 but ready for GTA01 implementation) + * + * (C) 2008 by Openmoko Inc. + * Author: Andy Green + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License charging_led 2 as + * published by the Free Software Foundation + * + */ + +#include +#include +#include +#include + +#include +#include + +#ifdef CONFIG_MACH_NEO1973_GTA02 +#include + +static enum neo1973_charging_led_modes charging_mode; + +static char *charging_led_mode_names[] = { + "Disabled", + "Aux LED", + "Power LED" +}; + +static ssize_t charging_led_read(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "0x%03X\n", gta02_get_pcb_revision()); +} + +static ssize_t charging_led_read(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "0x%03X\n", gta02_get_pcb_revision()); +} + + +static DEVICE_ATTR(pcb, 0644, charging_led_read, charging_led_write); + +static struct attribute *neo1973_charging_led_sysfs_entries[] = { + &dev_attr_pcb.attr, + NULL +}; + +static struct attribute_group neo1973_charging_led_attr_group = { + .name = NULL, + .attrs = neo1973_charging_led_sysfs_entries, +}; + +static int __init neo1973_charging_led_probe(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "starting\n"); + + switch (machine_arch_type) { +#ifdef CONFIG_MACH_NEO1973_GTA01 + case MACH_TYPE_NEO1973_GTA01: + return -EINVAL; +#endif /* CONFIG_MACH_NEO1973_GTA01 */ + default: + break; + } + + return sysfs_create_group(&pdev->dev.kobj, + &neo1973_charging_led_attr_group); +} + +static int neo1973_charging_led_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &neo1973_charging_led_attr_group); + return 0; +} + +static struct platform_driver neo1973_charging_led_driver = { + .probe = neo1973_charging_led_probe, + .remove = neo1973_charging_led_remove, + .driver = { + .name = "neo1973-charging-led", + }, +}; + +static int __devinit neo1973_charging_led_init(void) +{ + return platform_driver_register(&neo1973_charging_led_driver); +} + +static void neo1973_charging_led_exit(void) +{ + platform_driver_unregister(&neo1973_charging_led_driver); +} + +module_init(neo1973_charging_led_init); +module_exit(neo1973_charging_led_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andy Green "); +MODULE_DESCRIPTION("Neo1973 PCB charging_led"); +#endif diff --git a/drivers/misc/neo1973_pm_host.c b/drivers/misc/neo1973_pm_host.c new file mode 100644 index 00000000000..caa302eeb91 --- /dev/null +++ b/drivers/misc/neo1973_pm_host.c @@ -0,0 +1,101 @@ +/* + * Bluetooth PM code for the FIC Neo1973 GSM Phone + * + * (C) 2007 by Openmoko Inc. + * Author: Harald Welte + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation + * + */ + +#include +#include +#include +#include + +#include +#include + +#ifdef CONFIG_MACH_NEO1973_GTA02 +#include +#include + +static ssize_t pm_host_read(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", + pcf50633_gpio_get(gta02_pcf_pdata.pcf, PCF50633_GPO)); +} + +static ssize_t pm_host_write(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned long on = simple_strtoul(buf, NULL, 10); + + pcf50633_gpio_set(gta02_pcf_pdata.pcf, PCF50633_GPO, on); + + return count; +} + +static DEVICE_ATTR(hostmode, 0644, pm_host_read, pm_host_write); + +static struct attribute *neo1973_pm_host_sysfs_entries[] = { + &dev_attr_hostmode.attr, + NULL +}; + +static struct attribute_group neo1973_pm_host_attr_group = { + .name = NULL, + .attrs = neo1973_pm_host_sysfs_entries, +}; + +static int __init neo1973_pm_host_probe(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "starting\n"); + + switch (machine_arch_type) { +#ifdef CONFIG_MACH_NEO1973_GTA01 + case MACH_TYPE_NEO1973_GTA01: + return -EINVAL; +#endif /* CONFIG_MACH_NEO1973_GTA01 */ + default: + break; + } + + return sysfs_create_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group); +} + +static int neo1973_pm_host_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &neo1973_pm_host_attr_group); + return 0; +} + +static struct platform_driver neo1973_pm_host_driver = { + .probe = neo1973_pm_host_probe, + .remove = neo1973_pm_host_remove, + .driver = { + .name = "neo1973-pm-host", + }, +}; + +static int __devinit neo1973_pm_host_init(void) +{ + return platform_driver_register(&neo1973_pm_host_driver); +} + +static void neo1973_pm_host_exit(void) +{ + platform_driver_unregister(&neo1973_pm_host_driver); +} + +module_init(neo1973_pm_host_init); +module_exit(neo1973_pm_host_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andy Green "); +MODULE_DESCRIPTION("Neo1973 USB Host Power Management"); +#endif diff --git a/drivers/misc/neo1973_pm_resume_reason.c b/drivers/misc/neo1973_pm_resume_reason.c new file mode 100644 index 00000000000..62984a50a0a --- /dev/null +++ b/drivers/misc/neo1973_pm_resume_reason.c @@ -0,0 +1,147 @@ +/* + * Resume reason sysfs for the FIC Neo1973 GSM Phone + * + * (C) 2008 by Openmoko Inc. + * Author: Andy Green + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License resume_reason 2 as + * published by the Free Software Foundation + * + */ + +#include +#include +#include +#include +#include + +#include +#include + +#ifdef CONFIG_MACH_NEO1973_GTA02 +#include +#include +#endif + +static unsigned int *gstatus4_mapped; +static char *resume_reasons[][17] = { { /* GTA01 */ + "EINT00_NULL", + "EINT01_GSM", + "EINT02_NULL", + "EINT03_NULL", + "EINT04_JACK", + "EINT05_SDCARD", + "EINT06_AUXKEY", + "EINT07_HOLDKEY", + "EINT08_NULL", + "EINT09_NULL", + "EINT10_NULL", + "EINT11_NULL", + "EINT12_NULL", + "EINT13_NULL", + "EINT14_NULL", + "EINT15_NULL", + NULL +}, { /* GTA02 */ + "EINT00_ACCEL1", + "EINT01_GSM", + "EINT02_BLUETOOTH", + "EINT03_DEBUGBRD", + "EINT04_JACK", + "EINT05_WLAN", + "EINT06_AUXKEY", + "EINT07_HOLDKEY", + "EINT08_ACCEL2", + "EINT09_PMU", + "EINT10_NULL", + "EINT11_NULL", + "EINT12_GLAMO", + "EINT13_NULL", + "EINT14_NULL", + "EINT15_NULL", + NULL +} }; + +static ssize_t resume_reason_read(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int bit = 0; + char *end = buf; + int gta = !!machine_is_neo1973_gta02(); + + for (bit = 0; resume_reasons[gta][bit]; bit++) { + if ((*gstatus4_mapped) & (1 << bit)) + end += sprintf(end, "* %s\n", resume_reasons[gta][bit]); + else + end += sprintf(end, " %s\n", resume_reasons[gta][bit]); + +#ifdef CONFIG_MACH_NEO1973_GTA02 + if ((gta) && (bit == 9)); /* PMU */ +// end += pcf50633_report_resumers(gta02_pcf_pdata.pcf, end); +#endif + } + + return end - buf; +} + + +static DEVICE_ATTR(resume_reason, 0644, resume_reason_read, NULL); + +static struct attribute *neo1973_resume_reason_sysfs_entries[] = { + &dev_attr_resume_reason.attr, + NULL +}; + +static struct attribute_group neo1973_resume_reason_attr_group = { + .name = NULL, + .attrs = neo1973_resume_reason_sysfs_entries, +}; + +static int __init neo1973_resume_reason_probe(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "starting\n"); + + gstatus4_mapped = ioremap(0x560000BC /* GSTATUS4 */, 0x4); + if (!gstatus4_mapped) { + dev_err(&pdev->dev, "failed to ioremap() memory region\n"); + return -EINVAL; + } + + return sysfs_create_group(&pdev->dev.kobj, + &neo1973_resume_reason_attr_group); +} + +static int neo1973_resume_reason_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &neo1973_resume_reason_attr_group); + iounmap(gstatus4_mapped); + return 0; +} + +static struct platform_driver neo1973_resume_reason_driver = { + .probe = neo1973_resume_reason_probe, + .remove = neo1973_resume_reason_remove, + .driver = { + .name = "neo1973-resume", + }, +}; + +static int __devinit neo1973_resume_reason_init(void) +{ + return platform_driver_register(&neo1973_resume_reason_driver); +} + +static void neo1973_resume_reason_exit(void) +{ + platform_driver_unregister(&neo1973_resume_reason_driver); +} + +module_init(neo1973_resume_reason_init); +module_exit(neo1973_resume_reason_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andy Green "); +MODULE_DESCRIPTION("Neo1973 resume_reason"); diff --git a/drivers/misc/neo1973_pm_usbhost.c b/drivers/misc/neo1973_pm_usbhost.c new file mode 100644 index 00000000000..602e4309ccf --- /dev/null +++ b/drivers/misc/neo1973_pm_usbhost.c @@ -0,0 +1,132 @@ +/* + * Bluetooth PM code for the FIC Neo1973 GSM Phone + * + * (C) 2007 by OpenMoko Inc. + * Author: Harald Welte + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation + * + */ + +#include +#include +#include +#include + +#include +#include + +#ifdef CONFIG_MACH_NEO1973_GTA02 +#include +#include +#endif + +static ssize_t pm_usbhost_read(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", + pcf50633_gpio_get(pcf50633_global, PCF50633_GPO)); +} + +static ssize_t pm_usbhost_write(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned long on = simple_strtoul(buf, NULL, 10); + + pcf50633_gpio_set(pcf50633_global, PCF50633_GPO, on); + + return count; +} + +static DEVICE_ATTR(hostmode, 0644, pm_usbhost_read, pm_usbhost_write); + +#ifdef CONFIG_PM +static int neo1973_usbhost_suspend(struct platform_device *pdev, pm_message_t state) +{ + dev_dbg(&pdev->dev, "suspending\n"); + /* FIXME: The PMU should save the PMU status, and the GPIO code should + * preserve the GPIO level, so there shouldn't be anything left to do + * for us, should there? */ + + return 0; +} + +static int neo1973_usbhost_resume(struct platform_device *pdev) +{ + dev_dbg(&pdev->dev, "resuming\n"); + + return 0; +} +#else +#define neo1973_usbhost_suspend NULL +#define neo1973_usbhost_resume NULL +#endif + +static struct attribute *neo1973_usbhost_sysfs_entries[] = { + &dev_attr_hostmode.attr, + NULL +}; + +static struct attribute_group neo1973_usbhost_attr_group = { + .name = NULL, + .attrs = neo1973_usbhost_sysfs_entries, +}; + +static int __init neo1973_usbhost_probe(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "starting\n"); + + switch (machine_arch_type) { + +#ifdef CONFIG_MACH_NEO1973_GTA01 + case MACH_TYPE_NEO1973_GTA01: + return -EINVAL; +#endif /* CONFIG_MACH_NEO1973_GTA01 */ + +#ifdef CONFIG_MACH_NEO1973_GTA02 + case MACH_TYPE_NEO1973_GTA02: +/* race */ +/* pcf50633_gpio_set(pcf50633_global, PCF50633_GPO, 0); */ + break; +#endif /* CONFIG_MACH_NEO1973_GTA02 */ + } + + return sysfs_create_group(&pdev->dev.kobj, &neo1973_usbhost_attr_group); +} + +static int neo1973_usbhost_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &neo1973_usbhost_attr_group); + + return 0; +} + +static struct platform_driver neo1973_usbhost_driver = { + .probe = neo1973_usbhost_probe, + .remove = neo1973_usbhost_remove, + .suspend = neo1973_usbhost_suspend, + .resume = neo1973_usbhost_resume, + .driver = { + .name = "neo1973-pm-host", + }, +}; + +static int __devinit neo1973_usbhost_init(void) +{ + return platform_driver_register(&neo1973_usbhost_driver); +} + +static void neo1973_usbhost_exit(void) +{ + platform_driver_unregister(&neo1973_usbhost_driver); +} + +module_init(neo1973_usbhost_init); +module_exit(neo1973_usbhost_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andy Green "); +MODULE_DESCRIPTION("Neo1973 USB Host Power Management"); diff --git a/drivers/misc/neo1973_version.c b/drivers/misc/neo1973_version.c new file mode 100644 index 00000000000..a88172132dc --- /dev/null +++ b/drivers/misc/neo1973_version.c @@ -0,0 +1,90 @@ +/* + * PCB version sysfs for the FIC Neo1973 GSM Phone + * + * (C) 2007 by Openmoko Inc. + * Author: Andy Green + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation + * + */ + +#include +#include +#include +#include + +#include +#include + +#ifdef CONFIG_MACH_NEO1973_GTA02 +#include + +static ssize_t version_read(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "0x%03X\n", gta02_get_pcb_revision()); +} + + +static DEVICE_ATTR(pcb, 0644, version_read, NULL); + +static struct attribute *neo1973_version_sysfs_entries[] = { + &dev_attr_pcb.attr, + NULL +}; + +static struct attribute_group neo1973_version_attr_group = { + .name = NULL, + .attrs = neo1973_version_sysfs_entries, +}; + +static int __init neo1973_version_probe(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "starting\n"); + + switch (machine_arch_type) { +#ifdef CONFIG_MACH_NEO1973_GTA01 + case MACH_TYPE_NEO1973_GTA01: + return -EINVAL; +#endif /* CONFIG_MACH_NEO1973_GTA01 */ + default: + break; + } + + return sysfs_create_group(&pdev->dev.kobj, &neo1973_version_attr_group); +} + +static int neo1973_version_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &neo1973_version_attr_group); + return 0; +} + +static struct platform_driver neo1973_version_driver = { + .probe = neo1973_version_probe, + .remove = neo1973_version_remove, + .driver = { + .name = "neo1973-version", + }, +}; + +static int __devinit neo1973_version_init(void) +{ + return platform_driver_register(&neo1973_version_driver); +} + +static void neo1973_version_exit(void) +{ + platform_driver_unregister(&neo1973_version_driver); +} + +module_init(neo1973_version_init); +module_exit(neo1973_version_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andy Green "); +MODULE_DESCRIPTION("Neo1973 PCB version"); +#endif -- cgit v1.2.3