/
0008-capemgr-Priority-on-capemgr.enable_partno-option.patch
156 lines (135 loc) · 5.31 KB
/
0008-capemgr-Priority-on-capemgr.enable_partno-option.patch
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
From 43434d10b8231f7a5bdfb851aa1b41d54bf8fe6d Mon Sep 17 00:00:00 2001
From: Pantelis Antoniou <panto@antoniou-consulting.com>
Date: Wed, 24 Jul 2013 18:30:43 +0300
Subject: [PATCH 8/8] capemgr: Priority on capemgr.enable_partno option
When booting from a device that's providing the rootfs via a
cape fragment, you face the following problem as it appears
on the beaglebone black.
The priority of the emmc cape is low (positive number) so that
any cape that is detected and uses the resources of the emmc
interface can work (for example the camera cape). This means that
we have to be booting from external sd card.
However if there is no conflict, and the cape dtbo is not included
in the kernel (via the firmware builtin configure option) the capemgr
will attempt to load the cape too early, at a time that the rootfs
cape hasn't been loaded yet.
In order to fix that an optional third parameter is added to
the specification of a cape in the eanble_partno option which allow
you to specify the priority.
so capemgr.enable_partno=[PART[:REV[:PRIO]]][,PART..]
To load the cape fragment after all the builtin capes have loaded
use a priority higher than 10; i.e. to load cape foo use:
capemgr.enable_partno=foo:00A0:10
Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
---
drivers/misc/cape/beaglebone/capemgr.c | 44 +++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/drivers/misc/cape/beaglebone/capemgr.c b/drivers/misc/cape/beaglebone/capemgr.c
index ee6462d..3fcaef3 100644
--- a/drivers/misc/cape/beaglebone/capemgr.c
+++ b/drivers/misc/cape/beaglebone/capemgr.c
@@ -178,7 +178,7 @@ static int bone_slot_fill_override(struct bone_cape_slot *slot,
const char *part_number, const char *version);
static struct bone_cape_slot *bone_capemgr_add_slot(
struct bone_capemgr_info *info, struct device_node *node,
- const char *part_number, const char *version);
+ const char *part_number, const char *version, int prio);
static int bone_capemgr_remove_slot_no_lock(struct bone_cape_slot *slot);
static int bone_capemgr_remove_slot(struct bone_cape_slot *slot);
static int bone_capemgr_load(struct bone_cape_slot *slot);
@@ -1086,7 +1086,7 @@ found:
}
slot = bone_capemgr_add_slot(info, node,
- part_number, version);
+ part_number, version, 0);
if (IS_ERR(slot)) {
dev_err(&pdev->dev, "Failed to add slot #%d\n",
atomic_read(&info->next_slot_nr) - 1);
@@ -1104,7 +1104,7 @@ found:
/* no specific slot found, try immediate */
if (!slot)
slot = bone_capemgr_add_slot(info, NULL,
- part_number, version);
+ part_number, version, 0);
if (IS_ERR_OR_NULL(slot)) {
dev_err(&pdev->dev, "Failed to add slot #%d\n",
@@ -1618,7 +1618,7 @@ static int bone_slot_fill_override(struct bone_cape_slot *slot,
static struct bone_cape_slot *
bone_capemgr_add_slot(struct bone_capemgr_info *info, struct device_node *node,
- const char *part_number, const char *version)
+ const char *part_number, const char *version, int prio)
{
struct device_node *eeprom_node;
struct bone_cape_slot *slot;
@@ -1637,6 +1637,7 @@ bone_capemgr_add_slot(struct bone_capemgr_info *info, struct device_node *node,
}
slot->info = info;
slot->slotno = slotno;
+ slot->priority = prio;
if (node && !of_property_read_bool(node, "ti,cape-override")) {
ret = of_property_read_u32(node, "eeprom",
@@ -1894,7 +1895,8 @@ bone_capemgr_probe(struct platform_device *pdev)
const char *board_name;
const char *compatible_name;
struct bone_capemap *capemap;
- int ret, len;
+ int ret, len, prio;
+ long val;
char *wbuf, *s, *p, *e;
/* we don't use platform_data at all; we require OF */
@@ -2063,7 +2065,7 @@ bone_capemgr_probe(struct platform_device *pdev)
continue;
slot = bone_capemgr_add_slot(info, node,
- NULL, NULL);
+ NULL, NULL, 0);
if (IS_ERR(slot)) {
dev_err(&pdev->dev, "Failed to add slot #%d\n",
atomic_read(&info->next_slot_nr));
@@ -2090,7 +2092,7 @@ bone_capemgr_probe(struct platform_device *pdev)
/* add any enable_partno capes */
s = enable_partno;
while (*s) {
- /* form is PART[:REV],PART.. */
+ /* form is PART[:REV[:PRIO]],PART.. */
p = strchr(s, ',');
if (p == NULL)
e = s + strlen(s);
@@ -2107,20 +2109,34 @@ bone_capemgr_probe(struct platform_device *pdev)
/* move to the next */
s = *e ? e + 1 : e;
- /* now split the rev part */
+ part_number = wbuf;
+
+ /* default version is NULL & prio is 0 */
+ version = NULL;
+ prio = 0;
+
+ /* now split the rev & prio part */
p = strchr(wbuf, ':');
- if (p != NULL)
+ if (p != NULL) {
*p++ = '\0';
+ if (*p != ':')
+ version = p;
+ p = strchr(p, ':');
+ if (p != NULL) {
+ *p++ = '\0';
+ ret = kstrtol(p, 10, &val);
+ if (ret == 0)
+ prio = val;
+ }
+ }
- part_number = wbuf;
- version = p;
- dev_info(&pdev->dev, "enabled_partno part_number '%s', version '%s'\n",
- part_number, version ? version : "N/A");
+ dev_info(&pdev->dev, "enabled_partno part_number '%s', version '%s', prio '%d'\n",
+ part_number, version ? version : "N/A", prio);
/* only immediate slots are allowed here */
slot = bone_capemgr_add_slot(info, NULL,
- part_number, version);
+ part_number, version, prio);
/* we continue even in case of an error */
if (IS_ERR_OR_NULL(slot)) {
--
1.8.2.1