Skip to content

Commit 95a4070

Browse files
authored
Merge pull request #84 from stephan-gh/ftdi-usb1
drivers: ftdi-gpio: Add second USB disconnect GPIO & schema.yaml fixes
2 parents 4320c48 + 7209229 commit 95a4070

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

config-samples/sample8.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,32 @@ devices:
7373
power:
7474
interface: D
7575
line: 6
76+
- board: myboard-5
77+
name: "My Board 5"
78+
description: |
79+
My super awesome board Number 5
80+
console: /dev/ttyABC1
81+
fastboot: cacafada
82+
ftdi_gpio:
83+
vendor: "0x0403"
84+
product: "0x6011"
85+
index: 0
86+
power:
87+
interface: B
88+
line: 1
89+
active_low: true
90+
fastboot_key:
91+
interface: B
92+
line: 0
93+
active_low: true
94+
power_key:
95+
interface: B
96+
line: 2
97+
usb0_disconnect:
98+
interface: C
99+
line: 7
100+
active_low: true
101+
usb1_disconnect:
102+
interface: A
103+
line: 4
104+
active_low: true

drivers/ftdi-gpio.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ enum {
3131
GPIO_POWER = 0, // Power input enable
3232
GPIO_FASTBOOT_KEY, // Usually volume key
3333
GPIO_POWER_KEY, // Key to power the device
34-
GPIO_USB_DISCONNECT, // Simulate main USB connection
34+
GPIO_USB0_DISCONNECT, // Simulate main USB connection
35+
GPIO_USB1_DISCONNECT, // Simulate secondary USB connection
3536
GPIO_OUTPUT_ENABLE, // Enable FTDI signals to flow to the board
3637
GPIO_COUNT
3738
};
@@ -131,7 +132,7 @@ static void ftdi_gpio_parse_config(struct ftdi_gpio_options *options, char *valu
131132
else if (strncmp("POWER_KEY", name, off - name - 1) == 0)
132133
gpio_type = GPIO_POWER_KEY;
133134
else if (strncmp("USB_DISCONNECT", name, off - name - 1) == 0)
134-
gpio_type = GPIO_USB_DISCONNECT;
135+
gpio_type = GPIO_USB0_DISCONNECT;
135136
else if (strncmp("OUTPUT_ENABLE", name, off - name - 1) == 0)
136137
gpio_type = GPIO_OUTPUT_ENABLE;
137138
else
@@ -182,7 +183,11 @@ void *ftdi_gpio_parse_options(struct device_parser *dp)
182183
} else if (!strcmp(key, "power_key")) {
183184
gpio_id = GPIO_POWER_KEY;
184185
} else if (!strcmp(key, "usb_disconnect")) {
185-
gpio_id = GPIO_USB_DISCONNECT;
186+
gpio_id = GPIO_USB0_DISCONNECT;
187+
} else if (!strcmp(key, "usb0_disconnect")) {
188+
gpio_id = GPIO_USB0_DISCONNECT;
189+
} else if (!strcmp(key, "usb1_disconnect")) {
190+
gpio_id = GPIO_USB1_DISCONNECT;
186191
} else if (!strcmp(key, "output_enable")) {
187192
gpio_id = GPIO_OUTPUT_ENABLE;
188193
} else {
@@ -357,7 +362,8 @@ static int ftdi_gpio_device_power(struct ftdi_gpio *ftdi_gpio, bool on)
357362

358363
static void ftdi_gpio_device_usb(struct ftdi_gpio *ftdi_gpio, bool on)
359364
{
360-
ftdi_gpio_toggle_io(ftdi_gpio, GPIO_USB_DISCONNECT, on);
365+
ftdi_gpio_toggle_io(ftdi_gpio, GPIO_USB0_DISCONNECT, on);
366+
ftdi_gpio_toggle_io(ftdi_gpio, GPIO_USB1_DISCONNECT, on);
361367
}
362368

363369
static int ftdi_gpio_power(struct device *dev, bool on)

schema.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ properties:
123123
minimin: 0
124124
devicenode:
125125
$ref: "#/$defs/device_path"
126-
patternProperties:
127-
"^power|fastboot_key|power_key|usb_disconnect|output_enable$":
128-
$ref: "#/$defs/ftdi_gpio"
126+
patternProperties:
127+
"^power|fastboot_key|power_key|usb[01]?_disconnect|output_enable$":
128+
$ref: "#/$defs/ftdi_gpio"
129+
additionalProperties: false
129130

130131
dependentRequired:
131132
index:
@@ -138,15 +139,15 @@ properties:
138139
local_gpio:
139140
description: Local GPIO
140141
type: object
141-
unevaluatedItems: false
142+
additionalProperties: false
142143
patternProperties:
143144
"^power|fastboot_key|power_key|usb_disconnect$":
144145
$ref: "#/$defs/local_gpio"
145146

146147
laurent:
147148
description: KernelChip Laurent relays
148149
type: object
149-
unevaluatedItems: false
150+
additionalProperties: false
150151
properties:
151152
server:
152153
type: string

0 commit comments

Comments
 (0)