Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion arch/arm/boot/dts/nxp/imx/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# SPDX-License-Identifier: GPL-2.0

DTC_FLAGS_imx6ul-ts7250v3 := -@

dtb-$(CONFIG_SOC_IMX1) += \
imx1-ads.dtb \
imx1-apf9328.dtb
Expand Down Expand Up @@ -332,7 +335,6 @@ dtb-$(CONFIG_SOC_IMX6UL) += \
imx6ul-ts4100-8.dtb \
imx6ul-ts4100-16.dtb \
imx6ul-ts7250v3-reva.dtb \
imx6ul-ts7250v3.dtb \
imx6ul-ts7553v2.dtb \
imx6ul-ts7100-1.dtb \
imx6ul-ts7100-3.dtb \
Expand Down Expand Up @@ -375,6 +377,13 @@ dtb-$(CONFIG_SOC_IMX6UL) += \
imx6ull-tqma6ull2l-mba6ulx.dtb \
imx6ulz-14x14-evk.dtb \
imx6ulz-bsh-smm-m2.dtb

imx6ul-ts7250v3-silo104-i2c-gpio-dtbs := imx6ul-ts7250v3.dtb imx6ul-ts7250v3-silo104-i2c-gpio.dtbo
dtb-$(CONFIG_SOC_IMX6UL) += imx6ul-ts7250v3.dtb
dtb-$(CONFIG_SOC_IMX6UL) += imx6ul-ts7250v3-silo104-i2c-gpio.dtbo

DTC_FLAGS_imx6ul-ts7250v3-silo104-i2c-gpio := -@

dtb-$(CONFIG_SOC_IMX7D) += \
imx7d-cl-som-imx7.dtb \
imx7d-colibri-aster.dtb \
Expand Down
170 changes: 170 additions & 0 deletions arch/arm/boot/dts/nxp/imx/imx6ul-ts7250v3-silo104-i2c-gpio.dtso
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
fragment@0 {
target-path = "/";
__overlay__ {
i2c5_gpio: i2c-104 {
compatible = "i2c-gpio";

/* FPGA bank1 pins: SCL=13, SDA=8 */
scl-gpios = <&fpga_bank1 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
sda-gpios = <&fpga_bank1 8 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;

#address-cells = <1>;
#size-cells = <0>;
};
};
};

fragment@1 {
target-path = "/aliases";
__overlay__ {
i2c5 = &i2c5_gpio;
};
};

/* Add the wizard device tree under the i2c5_gpio bus */
fragment@2 {
target = <&i2c5_gpio>;
__overlay__ {
wizard: wizard@68 {
compatible = "technologic,wizard";
reg = <0x68>;

silo_wizard_adc: silo-wizard-adc {
compatible = "technologic,wizard-adc";
#io-channel-cells = <1>;
};

wizard_irq: silo-interrupt-controller {
compatible = "technologic,wizard-irq";
interrupt-parent = <&fpga_intc>;
interrupts = <17 IRQ_TYPE_LEVEL_HIGH>;

#interrupt-cells = <1>;
interrupt-controller;
};

wizard_silo: silo {
compatible = "technologic,wizard-silo";
interrupt-parent = <&fpga_intc>;
interrupts = <17 IRQ_TYPE_LEVEL_HIGH>;
};

wizard_temp: temperature-sensor {
compatible = "technologic,wizard-temp";
#io-channel-cells = <0>;
};

wizard_reset: reset-controller {
compatible = "technologic,wizard-reset";
#reset-cells = <1>;
};
};
};
};

/* ADC voltage-divider helpers for Silo104, channels 0..7 */
fragment@3 {
target-path = "/";
__overlay__ {

/* iio-rescale to reflect 1:1 scaling */
scap_junc_2: an-scap-junc-2 {
compatible = "iio-rescale";
io-channels = <&silo_wizard_adc 0>;
io-channel-names = "parent";
label = "silo-scap-junc-2";

numerator = <1>;
denominator = <1>;
type = "voltage";

#io-channel-cells = <0>;
};

silo_5v2mv_rail: an-silo-5v2mv-rail {
compatible = "voltage-divider";
io-channels = <&silo_wizard_adc 1>;
label = "silo-5v2mv-rail";
io-channel-names = "parent";
output-ohms = <75000>;
full-ohms = <150000>;
#io-channel-cells = <0>;
};

silo_scap_plus: an-scap-plus {
compatible = "voltage-divider";
io-channels = <&silo_wizard_adc 2>;
io-channel-names = "parent";
label = "an-scap-plus";
output-ohms = <75000>;
full-ohms = <150000>;
#io-channel-cells = <0>;
};

/* iio-rescale to reflect 1:1 scaling */
scap_junc_1: an-scap-junc-1 {
compatible = "iio-rescale";
io-channels = <&silo_wizard_adc 3>;
io-channel-names = "parent";
label = "silo-scap-junc-1";

numerator = <1>;
denominator = <1>;
type = "voltage";

#io-channel-cells = <0>;
};

scap_vchrg_mv: an-scap-vchrg-mv {
compatible = "voltage-divider";
io-channels = <&silo_wizard_adc 4>;
label = "scap-vchrg-mv";
io-channel-names = "parent";
output-ohms = <75000>;
full-ohms = <150000>;
#io-channel-cells = <0>;
};

silo_reg_5v: an-silo-reg-5v {
compatible = "voltage-divider";
io-channels = <&silo_wizard_adc 5>;
label = "silo-reg-5v";
output-ohms = <75000>;
full-ohms = <150000>;
#io-channel-cells = <0>;
};

silo_vin: an-silo-vin {
compatible = "voltage-divider";
io-channels = <&silo_wizard_adc 6>;
label = "silo-vin";
output-ohms = <4990>;
full-ohms = <79990>;
#io-channel-cells = <0>;
};

/* Total system current draw */
silo_sbc_current: an-silo-sbc-current {
compatible = "current-sense-amplifier";
io-channels = <&silo_wizard_adc 7>;
label = "system-current";
#io-channel-cells = <0>;

/* Effective shunt: R43 || R44 = 50 mOhm */
sense-resistor-micro-ohms = <50000>; /* 50 milliohm */

/* VSENSE->VOUT gain: 0.004 * (8.66k || 6.04k) ~= 14.233 V/V */
sense-gain-mult = <14233>;
sense-gain-div = <1000>;
};
};
};
};

1 change: 0 additions & 1 deletion arch/arm/boot/dts/nxp/imx/imx6ul-ts7250v3.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
wizard: wizard@10 {
compatible = "technologic,wizard";
reg = <0x10>;
status = "disabled";

wizard_adc: wizard_adc {
compatible = "technologic,wizard-adc";
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/configs/tsimx6ul_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_TS_WIZARD=y
CONFIG_POWER_RESET_SYSCON=y
CONFIG_POWER_RESET_SYSCON_POWEROFF=y
CONFIG_POWER_SUPPLY=y
CONFIG_TSSILO_SUPERCAPS=y
CONFIG_SENSORS_IIO_HWMON=y
CONFIG_THERMAL=y
CONFIG_THERMAL_STATISTICS=y
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/configs/tsimx6ul_minimal_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_TS_WIZARD=y
CONFIG_POWER_RESET_SYSCON=y
CONFIG_POWER_RESET_SYSCON_POWEROFF=y
CONFIG_POWER_SUPPLY=y
CONFIG_TSSILO_SUPERCAPS=y
CONFIG_SENSORS_IIO_HWMON=y
CONFIG_THERMAL=y
CONFIG_THERMAL_STATISTICS=y
Expand Down
9 changes: 5 additions & 4 deletions drivers/iio/adc/tswizard_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,24 @@ static int ts_wizard_adc_probe(struct platform_device *pdev)
indio_dev->num_channels = adc->channel_count;
indio_dev->channels = tswizard_channels;

indio_dev->name = dev_name(&pdev->dev);
indio_dev->name = (pdev->dev.of_node && pdev->dev.of_node->name) ? pdev->dev.of_node->name: dev_name(&pdev->dev);
indio_dev->dev.of_node = pdev->dev.of_node;
indio_dev->info = &ts_adc_info;

return devm_iio_device_register(&pdev->dev, indio_dev);
}

static const struct of_device_id tswizard_of_match[] = {
static const struct of_device_id tswizard_adc_of_match[] = {
{ .compatible = "technologic,tswizard-adc", },
{ .compatible = "technologic,wizard-adc", },
{ }
};
MODULE_DEVICE_TABLE(of, tsadc_of_match);
MODULE_DEVICE_TABLE(of, tswizard_adc_of_match);

static struct platform_driver tsadc_driver = {
.driver = {
.name = "tswizard-adc",
.of_match_table = tswizard_of_match,
.of_match_table = tswizard_adc_of_match,
},
.probe = ts_wizard_adc_probe,
};
Expand Down
58 changes: 51 additions & 7 deletions drivers/mfd/tswizard-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,72 @@
#include <linux/mfd/ts_wizard.h>

#define MODEL_TS_7250_V3 0x7250
#define MODEL_TS_SILO_104 0x5104

static struct mfd_cell tswizard_devs[] = {
{
.name = "tswizard-reset",
.id = -1,
.of_compatible = "technologic,wizard-reset",
.id = PLATFORM_DEVID_AUTO,
},
{
.name = "tswizard-temp",
.of_compatible = "technologic,wizard-temp",
.id = -1,
.id = PLATFORM_DEVID_AUTO,
},
{
.name = "tswizard-adc",
.of_compatible = "technologic,wizard-adc",
.id = -1,
.id = PLATFORM_DEVID_AUTO,
}
};

static struct mfd_cell silo104_devs[] = {
{
.name = "tswizard-irq",
.of_compatible = "technologic,wizard-irq",
.id = PLATFORM_DEVID_AUTO,
},
{
.name = "tswizard-reset",
.of_compatible = "technologic,wizard-reset",
.id = PLATFORM_DEVID_AUTO,
},
{
.name = "tswizard-silo",
.of_compatible = "technologic,wizard-silo",
.id = PLATFORM_DEVID_NONE,
},
{
.name = "tswizard-temp",
.of_compatible = "technologic,wizard-temp",
.id = PLATFORM_DEVID_AUTO,
},
{
.name = "tswizard-adc",
.of_compatible = "technologic,wizard-adc",
.id = PLATFORM_DEVID_AUTO,
},
};

static const struct regmap_range ts_wizard_read_regs[] = {
regmap_reg_range(0, 3), /* model/version/advertisements */
regmap_reg_range(16, 16), /* flags */
regmap_reg_range(24, 24), /* inputs */
regmap_reg_range(32, 32), /* reboot_reason */
regmap_reg_range(34, 37), /* serial */
regmap_reg_range(WIZ_SILO_BASE, WIZ_SILO_BASE +16), /* silo regs (64-80)*/
regmap_reg_range(128, 160), /* ADCs+temp */
};

static const struct regmap_range ts_wizard_write_regs[] = {
regmap_reg_range(8, 8), /* cmds */
regmap_reg_range(16, 16), /* flags */
regmap_reg_range(34, 37), /* serial */
regmap_reg_range(WIZ_SILO_BASE +2, WIZ_SILO_BASE +2), /* silo control (66)*/
regmap_reg_range(WIZ_SILO_BASE +4, WIZ_SILO_BASE +4), /* silo req chg current (68) */
regmap_reg_range(WIZ_SILO_BASE +9, WIZ_SILO_BASE +9), /* CRITICAL_PCT (base+9) */
regmap_reg_range(WIZ_SILO_BASE +12, WIZ_SILO_BASE +13), /* startup current (76), min pwr on pct (77) */
};

const struct regmap_access_table ts_wizard_read_register_set = {
Expand All @@ -64,7 +99,7 @@ const struct regmap_config ts_wizard_i2c_regmap = {
.rd_table = &ts_wizard_read_register_set,
.volatile_table = &ts_wizard_read_register_set,

.disable_locking = true,
.disable_locking = false,
.cache_type = REGCACHE_NONE,
};
EXPORT_SYMBOL_GPL(ts_wizard_i2c_regmap);
Expand Down Expand Up @@ -253,7 +288,7 @@ static int ts_wizard_i2c_probe(struct i2c_client *client)
{
struct ts_wizard *wiz;
struct device *dev = &client->dev;
int err = 0, i;
int err = 0, i, j;
uint32_t model, revision, features;

wiz = devm_kzalloc(dev, sizeof(struct ts_wizard),
Expand Down Expand Up @@ -297,15 +332,24 @@ static int ts_wizard_i2c_probe(struct i2c_client *client)
dev_warn(dev, "error creating sysfs entries\n");
}

if (model == MODEL_TS_SILO_104) {
err = mfd_add_devices(dev, PLATFORM_DEVID_AUTO, silo104_devs,
ARRAY_SIZE(silo104_devs), NULL, 0, NULL);
if (err) {
dev_err(dev, "Failed to add SILO104 devices: %d\n", err);
}
return err;
}

/* Set up and register the platform devices. */
for (i = 0; i < ARRAY_SIZE(tswizard_devs); i++) {
tswizard_devs[i].platform_data = wiz;
tswizard_devs[i].pdata_size = sizeof(struct ts_wizard);
}

return mfd_add_devices(dev, 0, tswizard_devs,
return mfd_add_devices(dev, PLATFORM_DEVID_AUTO, tswizard_devs,
ARRAY_SIZE(tswizard_devs), NULL, 0, NULL);
}
};

static const struct i2c_device_id ts_wizard_i2c_id[] = {
{ "tswizard", 0 },
Expand Down
9 changes: 9 additions & 0 deletions drivers/power/supply/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -952,4 +952,13 @@ config CHARGER_QCOM_SMB2
adds support for the SMB2 switch mode battery charger found
in PMI8998 and related PMICs.

config TSSILO_SUPERCAPS
tristate "embeddedTS SILO supercaps driver"
depends on I2C
select REGMAP_I2C
help
Say Y here to enable the embeddedTS TS-SILO supercapacitor driver.
This adds support for the TS-SILO supercapacitor unexpected shutdown
protection device.

endif # POWER_SUPPLY
2 changes: 2 additions & 0 deletions drivers/power/supply/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ obj-$(CONFIG_BATTERY_SURFACE) += surface_battery.o
obj-$(CONFIG_CHARGER_SURFACE) += surface_charger.o
obj-$(CONFIG_BATTERY_UG3105) += ug3105_battery.o
obj-$(CONFIG_CHARGER_QCOM_SMB2) += qcom_pmi8998_charger.o
obj-$(CONFIG_TSSILO_SUPERCAPS) += tssilo_supercaps.o

Loading