Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ description: |
currently supported; direction switching and PMU event interrupts are not.
Boards must reserve lines that must remain under firmware control.

The Aria D2257 used with the Apple A9X has 22 GPIOs whose input levels are
read as on the D2365 and latches 248 PMU events (31 bytes at 0x140/0x1c0),
with GPIO line N being event 0x30 + N.

The August D2400 used with the Apple A10X has 16 GPIOs whose input
levels are read as on the D2365; its line configuration is not known, so
they are inputs as the boot firmware set them up. It latches 256 PMU
Expand Down Expand Up @@ -55,6 +59,7 @@ properties:
- apple,d2186-pmic-gpio
- apple,d2207-pmic-gpio
- apple,d2255-pmic-gpio
- apple,d2257-pmic-gpio
- apple,d2333-pmic-gpio
- apple,d2355-pmic-gpio
- apple,d2365-pmic-gpio
Expand Down Expand Up @@ -163,6 +168,7 @@ allOf:
properties:
compatible:
enum:
- apple,d2257-pmic-gpio
- apple,d2365-pmic-gpio
- apple,d2400-pmic-gpio
then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ maintainers:
- Henrik Klee <henrik@goat-code.com>

description: |
The D2355 sets the Lightning input current on the iPad Pro 12.9-inch (2017).
A Tristar port controller identifies the attached source using the ADC in the
August PMIC. The charger controls the role of the USB device controller while
identifying the source.
The D2355 sets the Lightning input current on the iPad Pro 9.7-inch (2016)
and iPad Pro 12.9-inch (2017). A Tristar port controller identifies the
attached source using the ADC in the Aria or August PMIC. The charger
controls the role of the USB device controller while identifying the source.

allOf:
- $ref: power-supply.yaml#
Expand All @@ -32,7 +32,7 @@ properties:
items:
- description: Charger status register bank.
- description: Charger control register bank.
- description: ADC register bank in the August PMIC.
- description: ADC register bank in the Aria or August PMIC.

reg-names:
items:
Expand All @@ -43,7 +43,7 @@ properties:
interrupts-extended:
items:
- description: D2355 parent-line notification.
- description: August ADC conversion complete.
- description: Aria or August ADC conversion complete.
- description: D2355 source event 40.
- description: D2355 source event 42.
- description: D2355 source event 53.
Expand All @@ -54,7 +54,15 @@ properties:

apple,adc-pmic:
$ref: /schemas/types.yaml#/definitions/phandle
description: The August PMIC providing the ADC registers.
description: The Aria or August PMIC providing the ADC registers.

apple,usb-input-limit-calibration:
$ref: /schemas/types.yaml#/definitions/uint8-array
minItems: 24
maxItems: 24
description:
This unit's low-voltage input-current calibration, the ADT's /charger
usb-input-limit-calibration, filled in by the boot loader.

apple,usb-input-limit-calibration-hv:
$ref: /schemas/types.yaml#/definitions/uint8-array
Expand Down
60 changes: 59 additions & 1 deletion arch/arm64/boot/dts/apple/s8001-j127-j128.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,53 @@
status = "okay";
};

&i2c0 {
/*
* D2355 Lightning charger PMU (ADT i2c0/usb-charger): PMU events come
* on AP GPIO 211; the Aria PMIC's ADC samples the Tristar's lines
* (conversion complete is Aria event 184).
*/
d2355_pmic: pmic@75 {
compatible = "apple,d2355-pmic", "apple,i2c-pmic";
reg = <0x75>;
#address-cells = <1>;
#size-cells = <1>;

d2355_events: gpio {
compatible = "apple,d2355-pmic-gpio";
interrupt-controller;
#interrupt-cells = <2>;
interrupt-parent = <&pinctrl_ap>;
interrupts = <211 IRQ_TYPE_LEVEL_LOW>;
};

tristar_charger: charger@80 {
compatible = "apple,d2355-tristar-charger";
reg = <0x80 0x0a>, <0x443 0x0c>, <0x4000 0x03>;
reg-names = "status", "control", "adc";
/* The PMU line, Aria ADC done, then the source events. */
interrupts-extended = <&d2355_events 80 IRQ_TYPE_EDGE_RISING>,
<&aria_gpio 184 IRQ_TYPE_EDGE_RISING>,
<&d2355_events 40 IRQ_TYPE_EDGE_RISING>,
<&d2355_events 42 IRQ_TYPE_EDGE_RISING>,
<&d2355_events 53 IRQ_TYPE_EDGE_RISING>;
apple,tristar = <&tristar>;
apple,adc-pmic = <&pmic0>;
/* The boot loader adds this unit's 24-byte ADT calibration table. */
/* A conservative window, not Apple's production limits. */
apple,pack-limits = <150 350 3400000 4200000 (-2000000) 2000000>;
/* ADT /charger usb-input-limit-max = 2400 (iPadOS 16.7.16 20H392, J127/J128). */
input-current-limit-microamp = <2400000>;

port {
charger_usb: endpoint {
remote-endpoint = <&usbdev_role>;
};
};
};
};
};

/* The two CT709 ambient light sensors; m1n1 copies the calibration to als0. */
&i2c3 {
status = "okay";
Expand Down Expand Up @@ -71,7 +118,6 @@
touchscreen-size-x = <1536>;
touchscreen-size-y = <2048>;
};

&pmic0 {
backlight@b00 {
compatible = "apple,aria-pmic-bl";
Expand All @@ -87,6 +133,18 @@
compatible = "apple,s8001-bcm4355b3-bt";
};

/* The Lightning charger sets the data role once the source is known. */
&usbdev {
usb-psy-name = "lightning";
usb-role-switch;

port {
usbdev_role: endpoint {
remote-endpoint = <&charger_usb>;
};
};
};

&wifi {
compatible = "pci14e4,43dc";
};
17 changes: 17 additions & 0 deletions arch/arm64/boot/dts/apple/s8001-pro.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,29 @@
&i2c0 {
status = "okay";

/* ADT i2c0/tristar (tristar,cbtl1610 at 0x1a) on J98a/J99a/J127/J128. */
tristar: port-controller@1a {
compatible = "nxp,cbtl1610";
reg = <0x1a>;
};

pmic0: pmic@3c {
compatible = "apple,aria-pmic", "apple,i2c-pmic";
reg = <0x3c>;
#address-cells = <1>;
#size-cells = <1>;

/* ADT i2c0/pmu (pmu,d2257, AP GPIO 215) on J98a/J99a/J127/J128. */
aria_gpio: gpio {
compatible = "apple,d2257-pmic-gpio";
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
interrupt-parent = <&pinctrl_ap>;
interrupts = <215 IRQ_TYPE_LEVEL_LOW>;
};

rtc@500 {
compatible = "apple,aria-pmic-rtc", "apple,antigua-pmic-rtc";
reg = <0x500 0x10>;
Expand Down
28 changes: 28 additions & 0 deletions drivers/gpio/gpio-apple-d2365.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,30 @@ static const struct apple_pmic_gpio_info d2255_gpio_info = {
.output_update_mask = BIT(4) | BIT(3) | BIT(0),
};

/*
* Aria/D2257 (A9X): 31 event bytes at 0x140/0x1c0 (248 events),
* GPIO line N is event 0x30 + N, and ADC completion is event 184 (0xb8).
*/
static const struct apple_pmic_event_info d2257_event_info = {
.status_base = 0x140,
.mask_base = 0x1c0,
.bytes = 31,
.gpio_event = 0x30,
};

/*
* D2257 has 22 GPIOs whose input levels sit at 0x186, eight lines per byte,
* as on the D2333, D2365 and D2400. Leave direction and output setup to the
* boot firmware for now.
*/
static const struct apple_pmic_gpio_info d2257_gpio_info = {
.label = "d2257-pmic-gpio",
.ngpio = 22,
.input_base = 0x186,
.input_only = true,
.events = &d2257_event_info,
};

static const struct apple_pmic_gpio_info d2333_gpio_info = {
.label = "d2333-pmic-gpio",
.ngpio = ARRAY_SIZE(d2333_gpio_config_regs),
Expand Down Expand Up @@ -1358,6 +1382,10 @@ static const struct of_device_id d2365_gpio_of_match[] = {
.compatible = "apple,d2255-pmic-gpio",
.data = &d2255_gpio_info,
},
{
.compatible = "apple,d2257-pmic-gpio",
.data = &d2257_gpio_info,
},
{
.compatible = "apple,d2333-pmic-gpio",
.data = &d2333_gpio_info,
Expand Down
5 changes: 2 additions & 3 deletions drivers/power/supply/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ obj-$(CONFIG_APPLE_BELLATRIX_POWER) += apple_bellatrix_power.o
obj-$(CONFIG_APPLE_D2365_CHARGER) += apple_d2365_charger.o
obj-$(CONFIG_BATTERY_APPLE_D2186) += apple_d2186_battery.o
obj-$(CONFIG_APPLE_TRISTAR_CHARGER) += apple-tristar-charger.o
apple-tristar-charger-y := apple_tristar_charger.o
apple-tristar-charger-$(CONFIG_APPLE_TRISTAR_ACCESSORY) += apple_tristar_accessory.o \
apple_tristar_idbus.o
apple-tristar-charger-y := apple_tristar_charger.o apple_tristar_idbus.o
apple-tristar-charger-$(CONFIG_APPLE_TRISTAR_ACCESSORY) += apple_tristar_accessory.o
obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o
obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o
Expand Down
30 changes: 30 additions & 0 deletions drivers/power/supply/apple_d2355_calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#define D2355_CAL_POINTS 5
#define D2355_CAL_RANGES 4
#define D2355_CAL_LV_BYTES 24
#define D2355_CAL_HV_BYTES 84
#define D2355_CAL_ONE 65536

Expand Down Expand Up @@ -46,6 +47,35 @@ static inline int d2355_calibration_parse_hv(const void *data, size_t len,
return 0;
}

/*
* Low-voltage 24-byte format (A9X iPad Pro 9.7-inch): 5 Q16.16 measured
* points for range 0 followed by the trailing format selector word.
*/
static inline int d2355_calibration_parse_lv(const void *data, size_t len,
struct d2355_calibration *cal)
{
struct d2355_calibration parsed = {};
const u8 *bytes = data;
unsigned int point;
u32 word;

if (!data || !cal || len != D2355_CAL_LV_BYTES)
return -EINVAL;
parsed.selector = get_unaligned_le32(bytes + 4 * D2355_CAL_POINTS);
if (parsed.selector < 1 || parsed.selector > 3)
return -EINVAL;
for (point = 0; point < D2355_CAL_POINTS; point++) {
word = get_unaligned_le32(bytes + 4 * point);
if (!word || word > S32_MAX)
return -EINVAL;
if (point && word <= (u32)parsed.measured[0][point - 1])
return -EINVAL;
parsed.measured[0][point] = word;
}
*cal = parsed;
return 0;
}

/* Native public nominal landmarks; high ranges depend on format selector. */
static const s32 d2355_calibration_nominal[4][5] = {
{ 100, 500, 1000, 2100, 2400 },
Expand Down
Loading
Loading