summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mx5/devices_ccxmx5x.c
blob: 519f84735d188df8732ed435bc51e6c65e29012a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * Copyright 2011 Digi International, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

#include <linux/types.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/nodemask.h>
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/fsl_devices.h>
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
#include <linux/i2c.h>
#include <linux/ata.h>
#include <linux/regulator/consumer.h>
#include <linux/pmic_external.h>
#include <linux/pmic_status.h>
#include <linux/ipu.h>
#include <linux/mxcfb.h>
#include <linux/pwm_backlight.h>
#include <linux/smsc911x.h>
#include <linux/sysfs.h>
#include <mach/common.h>
#include <mach/hardware.h>
#include <asm/irq.h>
#include <asm/setup.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
#include <mach/memory.h>
#include <mach/gpio.h>
#include <mach/mmc.h>
#include <mach/mxc_dvfs.h>
#if defined(CONFIG_MODULE_CCXMX53)
#include <mach/iomux-mx53.h>
#endif

#include "devices_ccxmx5x.h"

static u8 ccxmx5x_mod_variant = 0;
static u8 ccxmx5x_mod_rev = 0;
static u32 ccxmx5x_mod_sn = 0;
static u8 ccxmx5x_bb_rev = BASE_BOARD_REV;

void ccxmx5x_set_mod_variant(u8 variant)
{
	ccxmx5x_mod_variant = variant;
}
void ccxmx5x_set_mod_revision(u8 revision)
{
	ccxmx5x_mod_rev = revision;
}
u8 ccxmx5x_get_mod_revision(void)
{
	return ccxmx5x_mod_rev;
}
void ccxmx5x_set_mod_sn(u32 sn)
{
	ccxmx5x_mod_sn = sn;
}

#ifdef CONFIG_SYSFS
static ssize_t ccxmx5x_mod_variant_attr_show(struct kobject *kobj,
					     struct kobj_attribute *attr, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%d\n", ccxmx5x_mod_variant);
}

static ssize_t ccxmx5x_mod_rev_attr_show(struct kobject *kobj,
					 struct kobj_attribute *attr, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%d\n", ccxmx5x_mod_rev);
}

static ssize_t ccxmx5x_mod_sn_attr_show(struct kobject *kobj,
					struct kobj_attribute *attr, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%d\n", ccxmx5x_mod_sn);
}

static ssize_t ccxmx5x_bb_rev_attr_show(struct kobject *kobj,
					struct kobj_attribute *attr, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%d\n", ccxmx5x_bb_rev);
}

static struct kobj_attribute ccxmx5x_mod_variant_attr =
	__ATTR(mod_variant, S_IRUGO, ccxmx5x_mod_variant_attr_show, NULL);
static struct kobj_attribute ccxmx5x_mod_rev_attr =
	__ATTR(mod_rev, S_IRUGO, ccxmx5x_mod_rev_attr_show, NULL);
static struct kobj_attribute ccxmx5x_mod_sn_attr =
	__ATTR(mod_sn, S_IRUGO, ccxmx5x_mod_sn_attr_show, NULL);
static struct kobj_attribute ccxmx5x_bb_rev_attr =
	__ATTR(bb_rev, S_IRUGO, ccxmx5x_bb_rev_attr_show, NULL);

int ccxmx5x_create_sysfs_entries(void)
{
	struct kobject *ccxmx5x_kobj;
	int ret;

	ccxmx5x_kobj = kobject_create_and_add(CCXMX5X_SYSFS_FNAME, kernel_kobj);
	if (!ccxmx5x_kobj) {
		printk(KERN_WARNING "kobject_create_and_add %s failed\n",
		       CCXMX5X_SYSFS_FNAME);
		return -EINVAL;
	}

	ret = sysfs_create_file(ccxmx5x_kobj, &ccxmx5x_mod_variant_attr.attr);
	if (ret) {
		printk(KERN_ERR
		       "Unable to register sysdev entry for %s hardware variant\n",
		       CCXMX5X_SYSFS_FNAME);
		return ret;
	}
	ret = sysfs_create_file(ccxmx5x_kobj, &ccxmx5x_mod_rev_attr.attr);
	if (ret) {
		printk(KERN_ERR
		       "Unable to register sysdev entry for %s hardware revision\n",
		       CCXMX5X_SYSFS_FNAME);
		return ret;
	}
	ret = sysfs_create_file(ccxmx5x_kobj, &ccxmx5x_mod_sn_attr.attr);
	if (ret) {
		printk(KERN_ERR
		       "Unable to register sysdev entry for %s hardware SN\n",
		       CCXMX5X_SYSFS_FNAME);
		return ret;
	}
	ret = sysfs_create_file(ccxmx5x_kobj, &ccxmx5x_bb_rev_attr.attr);
	if (ret) {
		printk(KERN_ERR
		       "Unable to register sysdev entry for %s base board hardware revision\n",
		       CCXMX5X_SYSFS_FNAME);
		return ret;
	}

	return 0;
}
#else
int ccxmx5x_create_sysfs_entries(void) { return 0; }
#endif /* CONFIG_SYSFS */