-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Risca/topic-nanopi-r2s-disconnect
nanopi-r2s: add support for disconnecting LAN port
- Loading branch information
Showing
7 changed files
with
9,362 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
while getopts "b:d:P:p:" o; do | ||
case "${o}" in | ||
p) | ||
p=${OPTARG} | ||
;; | ||
*) | ||
# ignore | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
if [ -z "${p}" ]; then | ||
exit 1 | ||
fi | ||
|
||
if [ "${p}" == "0" ]; then | ||
# Avoid error spam from driver | ||
rmmod r8152 | ||
echo 0 > /sys/devices/platform/lan-switch/state | ||
else | ||
echo 1 > /sys/devices/platform/lan-switch/state | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...rpatches/kernel/rockchip64-current/0001-regulator-userspace-consumer-add-dt-support.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
From f003651c631a0a25832600e7446cd562f80c52a7 Mon Sep 17 00:00:00 2001 | ||
From: Laxman Dewangan <[email protected]> | ||
Date: Wed, 30 Jul 2014 19:23:59 +0530 | ||
Subject: [PATCH 1/2] regulator: userspace-consumer: add DT support | ||
|
||
Add DT support of the regulator driver userspace-consumer. | ||
The supply names for this driver is provided through DT properties | ||
so that proper regulator handle can be acquired. | ||
|
||
Signed-off-by: Laxman Dewangan <[email protected]> | ||
--- | ||
drivers/regulator/userspace-consumer.c | 48 ++++++++++++++++++++++++++ | ||
1 file changed, 48 insertions(+) | ||
|
||
diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c | ||
index 765acc11c9c8..91d50a2770c0 100644 | ||
--- a/drivers/regulator/userspace-consumer.c | ||
+++ b/drivers/regulator/userspace-consumer.c | ||
@@ -23,6 +23,7 @@ | ||
#include <linux/regulator/consumer.h> | ||
#include <linux/regulator/userspace-consumer.h> | ||
#include <linux/slab.h> | ||
+#include <linux/of.h> | ||
|
||
struct userspace_consumer_data { | ||
const char *name; | ||
@@ -105,6 +106,41 @@ static const struct attribute_group attr_group = { | ||
.attrs = attributes, | ||
}; | ||
|
||
+static struct regulator_userspace_consumer_data *get_pdata_from_dt_node( | ||
+ struct platform_device *pdev) | ||
+{ | ||
+ struct regulator_userspace_consumer_data *pdata; | ||
+ struct device_node *np = pdev->dev.of_node; | ||
+ struct property *prop; | ||
+ const char *supply; | ||
+ int num_supplies; | ||
+ int count = 0; | ||
+ | ||
+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
+ if (!pdata) | ||
+ return ERR_PTR(-ENOMEM); | ||
+ | ||
+ pdata->name = of_get_property(np, "regulator-name", NULL); | ||
+ pdata->init_on = of_property_read_bool(np, "regulator-boot-on"); | ||
+ | ||
+ num_supplies = of_property_count_strings(np, "regulator-supplies"); | ||
+ if (num_supplies < 0) { | ||
+ dev_err(&pdev->dev, | ||
+ "could not parse property regulator-supplies\n"); | ||
+ return ERR_PTR(-EINVAL); | ||
+ } | ||
+ pdata->num_supplies = num_supplies; | ||
+ pdata->supplies = devm_kzalloc(&pdev->dev, num_supplies * | ||
+ sizeof(*pdata->supplies), GFP_KERNEL); | ||
+ if (!pdata->supplies) | ||
+ return ERR_PTR(-ENOMEM); | ||
+ | ||
+ of_property_for_each_string(np, "regulator-supplies", prop, supply) | ||
+ pdata->supplies[count++].supply = supply; | ||
+ | ||
+ return pdata; | ||
+} | ||
+ | ||
static int regulator_userspace_consumer_probe(struct platform_device *pdev) | ||
{ | ||
struct regulator_userspace_consumer_data *pdata; | ||
@@ -112,6 +148,11 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) | ||
int ret; | ||
|
||
pdata = dev_get_platdata(&pdev->dev); | ||
+ if (!pdata && pdev->dev.of_node) { | ||
+ pdata = get_pdata_from_dt_node(pdev); | ||
+ if (IS_ERR(pdata)) | ||
+ return PTR_ERR(pdata); | ||
+ } | ||
if (!pdata) | ||
return -EINVAL; | ||
|
||
@@ -171,11 +212,18 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev) | ||
return 0; | ||
} | ||
|
||
+static const struct of_device_id regulator_userspace_consumer_of_match[] = { | ||
+ { .compatible = "reg-userspace-consumer", }, | ||
+ {}, | ||
+}; | ||
+MODULE_DEVICE_TABLE(of, regulator_userspace_consumer_of_match); | ||
+ | ||
static struct platform_driver regulator_userspace_consumer_driver = { | ||
.probe = regulator_userspace_consumer_probe, | ||
.remove = regulator_userspace_consumer_remove, | ||
.driver = { | ||
.name = "reg-userspace-consumer", | ||
+ .of_match_table = regulator_userspace_consumer_of_match, | ||
}, | ||
}; | ||
|
||
-- | ||
2.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Patch naming matters! | ||
|
||
armbian build scripts will apply its own patches and the patches here in alpha- | ||
betical order, which means that special care needs to be taken if any custom | ||
patches modifies files introduced by armbian, e.g. | ||
nanopi-r2s-move-vcc_rtl8153-regulator-to-userspace.patch |
32 changes: 32 additions & 0 deletions
32
...atches/kernel/rockchip64-current/nanopi-r2s-move-vcc_rtl8153-regulator-to-userspace.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
dt: nanopi-r2s: move vcc_rtl8153 regulator to userspace | ||
|
||
This changes the vcc_rtl8153 so it's no longer "always-on", but instead | ||
depends on number of consumers. Add a userspace regulator consumer and | ||
make it on by default. | ||
|
||
diff --git a/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2-rev00.dts b/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2-rev00.dts | ||
index 717b1b2ed..fc88d49da 100644 | ||
--- a/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2-rev00.dts | ||
+++ b/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2-rev00.dts | ||
@@ -36,13 +36,20 @@ vcc_rtl8153: vcc-rtl8153-regulator { | ||
gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; | ||
pinctrl-names = "default"; | ||
pinctrl-0 = <&usb30_en_drv>; | ||
- regulator-always-on; | ||
regulator-name = "vcc_rtl8153"; | ||
regulator-min-microvolt = <5000000>; | ||
regulator-max-microvolt = <5000000>; | ||
off-on-delay-us = <5000>; | ||
enable-active-high; | ||
}; | ||
+ | ||
+ lan-switch { | ||
+ compatible = "reg-userspace-consumer"; | ||
+ regulator-name = "rtl8153-regulator-consumer"; | ||
+ regulator-boot-on; | ||
+ regulator-supplies = "vdd5"; | ||
+ vdd5-supply = <&vcc_rtl8153>; | ||
+ }; | ||
}; | ||
|
||
&mach { |
Oops, something went wrong.