From 6bef71f4feffd7cad99b14edf952f4b360c63d34 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 19 Nov 2008 17:09:35 +0000 Subject: add-pcb-rev-sysfs.patch Signed-off-by: Andy Green --- arch/arm/plat-s3c24xx/Makefile | 6 ++- arch/arm/plat-s3c24xx/neo1973_version.c | 90 +++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 arch/arm/plat-s3c24xx/neo1973_version.c (limited to 'arch/arm/plat-s3c24xx') diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile index 096dd624cfc..cf78e07528e 100644 --- a/arch/arm/plat-s3c24xx/Makefile +++ b/arch/arm/plat-s3c24xx/Makefile @@ -43,4 +43,8 @@ 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_pm_host.o neo1973_pm_gsm.o neo1973_pm_gps.o neo1973_pm_bt.o +obj-$(CONFIG_MACH_NEO1973) += neo1973_version.o \ + neo1973_pm_host.o \ + neo1973_pm_gsm.o \ + neo1973_pm_gps.o \ + neo1973_pm_bt.o diff --git a/arch/arm/plat-s3c24xx/neo1973_version.c b/arch/arm/plat-s3c24xx/neo1973_version.c new file mode 100644 index 00000000000..ad41a0f77b2 --- /dev/null +++ b/arch/arm/plat-s3c24xx/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