diff --git a/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml b/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml index 6f6ef56aafe4be..d551bfb45ec70e 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml @@ -37,6 +37,7 @@ properties: - apple,d201-touchscreen - apple,d21-touchscreen - apple,d79-touchscreen + - apple,n51-touchscreen - apple,n61-touchscreen - apple,n102-touchscreen - apple,n66-touchscreen @@ -416,6 +417,7 @@ allOf: - apple,j127-touchscreen - apple,j207-touchscreen - apple,j208-touchscreen + - apple,n51-touchscreen - apple,n61-touchscreen - apple,n102-touchscreen - apple,n66-touchscreen @@ -515,7 +517,9 @@ allOf: - if: properties: compatible: - const: apple,n61-touchscreen + enum: + - apple,n51-touchscreen + - apple,n61-touchscreen then: properties: apple,z2-cal-blob: diff --git a/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml b/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml index 6f3d9c558b9a05..1c757d8d1a7599 100644 --- a/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml @@ -29,6 +29,7 @@ properties: - apple,adelyn-cam-avdd3-regulator - apple,adelyn-cam0-regulator - apple,adelyn-touch-core-regulator + - apple,amber-touch-core-regulator - apple,angel-touch-analog-regulator - apple,antigua-cam-avdd-regulator - apple,antigua-cam0-regulator diff --git a/Documentation/devicetree/bindings/usb/apple,s5l8960x-hsic-wlan.yaml b/Documentation/devicetree/bindings/usb/apple,s5l8960x-hsic-wlan.yaml index ed0ac5230e7d9a..14c95cbadd8c75 100644 --- a/Documentation/devicetree/bindings/usb/apple,s5l8960x-hsic-wlan.yaml +++ b/Documentation/devicetree/bindings/usb/apple,s5l8960x-hsic-wlan.yaml @@ -45,6 +45,31 @@ properties: minimum: 1 description: The EHCI root port of the radio + apple,pmu-reset: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: The PMIC whose GPIO resets the radio + - description: That PMIC GPIO line (0 to 15) + maximum: 15 + description: + The radio's reset, the ADT wlan node's function-device_reset. Without + it, the reset is GPIO 3 of the D2089 at I2C 0x3c, as on the A7 iPads. + + apple,rom-chip: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The chip ID the radio's boot ROM reports (the ADT's /product + wifi-chipset), 43342 on the iPhone 5s. Without it, 0x4324 (the + iPads' BCM43241). + + apple,usb-pid: + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 0xffff + description: + The USB product ID (vendor 0a5c) of the radio's boot ROM: 0xbd21 on the + iPhone 5s. Without it, 0xbd1c (the iPads' BCM43241). + host-ready-gpios: maxItems: 1 description: HOST_READY, driven by the host diff --git a/arch/arm64/boot/dts/apple/s5l8960x-5s.dtsi b/arch/arm64/boot/dts/apple/s5l8960x-5s.dtsi index c0312ccbfc2622..d3743686daae6f 100644 --- a/arch/arm64/boot/dts/apple/s5l8960x-5s.dtsi +++ b/arch/arm64/boot/dts/apple/s5l8960x-5s.dtsi @@ -14,6 +14,10 @@ / { chassis-type = "handset"; + aliases { + touchscreen0 = &touchscreen; /* the loader copies the ADT calibration */ + }; + gpio-keys { compatible = "gpio-keys"; @@ -62,7 +66,7 @@ &i2c0 { status = "okay"; - pmic@74 { + pmu: pmic@74 { compatible = "apple,amber-pmic", "apple,i2c-pmic"; reg = <0x74>; #address-cells = <1>; @@ -89,6 +93,79 @@ }; }; }; + + /* ADT multi-touch function-power_ldo = pmuL(0x20e) */ + touch_core: regulator-touch-core { + compatible = "apple,amber-touch-core-regulator"; + regulator-name = "touch-core"; + }; + }; + + /* ADT display-pmu,chestnut @0x27: touch function-power_ana = dpLE(0x302) */ + display-pmu@27 { + compatible = "apple,chestnut-pmic"; + reg = <0x27>; + + touch_ana: regulator-touch-hv { + compatible = "apple,chestnut-touch-hv-regulator"; + regulator-name = "touch-analog"; + }; + }; +}; + +/* + * The touchscreen: an N1 on SPI1, the N51 ADT's /arm-io/spi1/multi-touch + * (multi-touch,n51): chip select GPIO 71 (SPI1's own), attention GPIO 22, + * reset GPIO 23, the PWM's 32768 Hz touch clock, the analog supply on the + * Chestnut and the LDO on the D2045. N51 and N53 share one kernelcache in + * iOS 12.5.8, whose only 5s touch personality matches multi-touch,n51, and + * identical N51.mtprops and N53.mtprops (C1F57,3). + */ +&touchclk { + status = "okay"; +}; + +&spi1 { + status = "okay"; + + touchscreen: touchscreen@0 { + compatible = "apple,n51-touchscreen"; + reg = <0>; + spi-max-frequency = <500000>; + interrupts-extended = <&pinctrl 22 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&pinctrl 23 GPIO_ACTIVE_LOW>; + ana-supply = <&touch_ana>; + core-supply = <&touch_core>; + clocks = <&touchclk>; + firmware-name = "apple/n51-fwstart.z2fw"; + touchscreen-size-x = <640>; + touchscreen-size-y = <1136>; + }; +}; + +/ { + /* + * The BCM43342 Wi-Fi radio on HSIC (the N51 ADT's + * /arm-io/usb-complex/usb-ehci1/wlan, module 'chardonnay', /product + * wifi-chipset 43342): EHCI1 root port 1, its HSIC PHY at usb-complex + * +0x60, HOST_READY on GPIO 166, DEVICE_READY on GPIO 167 and the + * reset on the D2045's GPIO 10 (function-device_reset), as on the iPad + * mini 2 but for the pins and the PMIC. Its boot ROM enumerates as + * 0a5c:bd21 (N51, 2026-12-04). apple-a7-wlan owns it. + */ + wifi@20c000060 { + compatible = "apple,s5l8960x-hsic-wlan"; + reg = <0x2 0x0c000060 0x0 0x10>, <0x2 0x0c400000 0x0 0x10000>; + reg-names = "phy", "ehci"; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_hsic2_phy>; + apple,ehci-port = <1>; + apple,pmu-reset = <&pmu 10>; + apple,rom-chip = <43342>; + apple,usb-pid = <0xbd21>; + host-ready-gpios = <&pinctrl 166 GPIO_ACTIVE_HIGH>; + device-ready-gpios = <&pinctrl 167 GPIO_ACTIVE_HIGH>; }; }; diff --git a/drivers/input/touchscreen/apple_z2.c b/drivers/input/touchscreen/apple_z2.c index be8f12ed4982d9..94e4fd45e63d4a 100644 --- a/drivers/input/touchscreen/apple_z2.c +++ b/drivers/input/touchscreen/apple_z2.c @@ -6041,6 +6041,21 @@ static const struct apple_z2_chip_info apple_z2_n61_info = { .cs_inactive_us = 1000, }; +/* + * The iPhone 5s (N51 and N53, which ship the same N51.mtprops) has the + * N61's generation-1 runtime: its iOS 12.5.8 personality "C1,N51" + * (C1F57,3) is AppleMultitouchN1SPI with the N61's calibration download + * (0x10009000) and proximity (0x10009600) addresses, fll-mval 6099, + * ref-clk-div 2, clk32 enable and execute address 0x10003400. + */ +static const struct apple_z2_chip_info apple_z2_n51_info = { + .name = "iPhone 5s Touchscreen", + .variant = APPLE_Z2_VARIANT_N61, + .cs_setup_us = 1000, + .cs_hold_us = 1000, + .cs_inactive_us = 1000, +}; + /* * The N56 shares the N61's generation-1 runtime protocol, its SPI chip * select timings and its calibration addresses; only the panel (and with @@ -6595,6 +6610,7 @@ static const struct of_device_id apple_z2_of_match[] = { { .compatible = "apple,d201-touchscreen", .data = &apple_z2_iphone8_gsm_info }, { .compatible = "apple,d79-touchscreen", .data = &apple_z2_d79_info }, { .compatible = "apple,d21-touchscreen", .data = &apple_z2_iphone8_plus_info }, + { .compatible = "apple,n51-touchscreen", .data = &apple_z2_n51_info }, { .compatible = "apple,n61-touchscreen", .data = &apple_z2_n61_info }, { .compatible = "apple,n56-touchscreen", .data = &apple_z2_n56_info }, { .compatible = "apple,n102-touchscreen", .data = &apple_z2_n102_info }, @@ -6629,6 +6645,7 @@ static struct spi_device_id apple_z2_of_id[] = { { .name = "d201-touchscreen", .driver_data = (kernel_ulong_t)&apple_z2_iphone8_gsm_info }, { .name = "d79-touchscreen", .driver_data = (kernel_ulong_t)&apple_z2_d79_info }, { .name = "d21-touchscreen", .driver_data = (kernel_ulong_t)&apple_z2_iphone8_plus_info }, + { .name = "n51-touchscreen", .driver_data = (kernel_ulong_t)&apple_z2_n51_info }, { .name = "n61-touchscreen", .driver_data = (kernel_ulong_t)&apple_z2_n61_info }, { .name = "n56-touchscreen", .driver_data = (kernel_ulong_t)&apple_z2_n56_info }, { .name = "n102-touchscreen", .driver_data = (kernel_ulong_t)&apple_z2_n102_info }, diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index d472ac847a52de..4b6ce21ba4c0a9 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -66,11 +66,25 @@ static const struct brcmf_firmware_mapping brcmf_usb_fwnames[] = { }; /* The HSIC radio's firmware is per board, because Apple's TRX for it carries - * the module NVRAM of that board: brcm/brcmfmac43241--usb.bin, where + * the module NVRAM of that board: brcm/brcmfmac--usb.bin, where * is the machine's first compatible without its "apple," prefix - * (brcmfmac43241-j72-usb.bin on the J72). + * (brcmfmac43241-j72-usb.bin on the J72, brcmfmac43342-n51-usb.bin on the + * iPhone 5s). */ -#define BRCMF_USB_HSIC_FW_FMT BRCMF_FW_DEFAULT_PATH "brcmfmac43241-%s-usb" +#define BRCMF_USB_HSIC_FW_FMT BRCMF_FW_DEFAULT_PATH "brcmfmac%s-%s-usb" + +/* The HSIC radios: the boot ROM's chip ID, the firmware's chip name and the + * largest RAM the ROM may report. The A7 iPads' BCM43241 reports 0x4324 + * (J72 measured: rev 6, 0x90000 bytes at 0x60000000). + */ +static const struct brcmf_usb_hsic_chip { + u32 chip; + const char *name; + u32 max_ramsize; +} brcmf_usb_hsic_chips[] = { + { BRCM_CC_43241_CHIP_ID, "43241", 0x90000 }, + { BRCM_CC_43342_CHIP_ID, "43342", 0x90000 }, /* iPhone 5s */ +}; /* Measured on J72; the reference on every board. */ #define BRCMF_USB_HSIC_ROM_REV 6 @@ -80,6 +94,8 @@ static const struct brcmf_firmware_mapping brcmf_usb_fwnames[] = { /* Cascadia: the iPad mini 1's BCM4334 on HSIC, as both its boot ROM and * Apple's firmware enumerate ("M=HEIN m=2.6 V=t", bcdDevice 0.01). */ #define BRCM_USB_APPLE_HSIC_DEVICE_ID 0xbd1c +/* The iPhone 5s BCM43342 boot ROM. */ +#define BRCM_USB_APPLE_HSIC_43342_DEVICE_ID 0xbd21 /* Cascadia: how long that firmware gets to start before its bus is reset */ #define BRCMF_USB_HSIC_BOOT_WAIT 500 /* in unit of ms */ @@ -185,6 +201,7 @@ struct brcmf_usbdev_info { struct usb_device *usbdev; bool hsic_reenum; /* Cascadia: firmware started, reset the bus */ u32 hsic_ramsize; /* ROM-reported RAM, bounds the HSIC image */ + const struct brcmf_usb_hsic_chip *hsic_chip; struct device *dev; struct completion dev_init_done; @@ -854,7 +871,8 @@ static bool brcmf_usb_hsic_radio(struct usb_device *udev) bool described; if (le16_to_cpu(udev->descriptor.idVendor) != BRCM_USB_VENDOR_ID_BROADCOM || - le16_to_cpu(udev->descriptor.idProduct) != BRCM_USB_APPLE_HSIC_DEVICE_ID) + (le16_to_cpu(udev->descriptor.idProduct) != BRCM_USB_APPLE_HSIC_DEVICE_ID && + le16_to_cpu(udev->descriptor.idProduct) != BRCM_USB_APPLE_HSIC_43342_DEVICE_ID)) return false; np = of_find_compatible_node(NULL, NULL, "apple,s5l8960x-hsic-wlan"); described = np && of_device_is_available(np); @@ -956,21 +974,27 @@ static int brcmf_usb_hsic_rom(struct brcmf_usbdev_info *devinfo, { u32 chipid = le32_to_cpu(id->chip), chiprev = le32_to_cpu(id->chiprev); u32 ramsize = le32_to_cpu(id->ramsize), remap = le32_to_cpu(id->remapbase); + unsigned int i; bool j72 = chiprev == BRCMF_USB_HSIC_ROM_REV && ramsize == BRCMF_USB_HSIC_ROM_RAMSIZE && remap == BRCMF_USB_HSIC_ROM_REMAP; if (chipid == BRCMF_POSTBOOT_ID) return 0; - /* Every A7 board's ADT names the chipset 4324. */ - if (chipid != BRCM_CC_43241_CHIP_ID) + for (i = 0; i < ARRAY_SIZE(brcmf_usb_hsic_chips); i++) + if (brcmf_usb_hsic_chips[i].chip == chipid) + devinfo->hsic_chip = &brcmf_usb_hsic_chips[i]; + if (!devinfo->hsic_chip) { + brcmf_err("HSIC ROM chip %#x rev %u ram %#x remap %#x is not known\n", + chipid, chiprev, ramsize, remap); return -ENODEV; + } if (!j72) brcmf_info("HSIC ROM rev %u ram %#x remap %#x, J72 measured rev %u ram %#x remap %#x\n", chiprev, ramsize, remap, BRCMF_USB_HSIC_ROM_REV, BRCMF_USB_HSIC_ROM_RAMSIZE, BRCMF_USB_HSIC_ROM_REMAP); /* chiprev selects the firmware by BIT(chiprev) */ - if (chiprev >= 32 || !ramsize || ramsize > BRCMF_USB_HSIC_ROM_RAMSIZE) + if (chiprev >= 32 || !ramsize || ramsize > devinfo->hsic_chip->max_ramsize) return -ENODEV; devinfo->hsic_ramsize = ramsize; return 0; @@ -989,7 +1013,8 @@ static int brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo) if (brcmf_usb_is_hsic(devinfo)) { ret = brcmf_usb_hsic_rom(devinfo, &id); if (ret) return ret; - devinfo->bus_pub.devid = BRCM_CC_43241_CHIP_ID; + devinfo->bus_pub.devid = devinfo->hsic_chip ? devinfo->hsic_chip->chip : + BRCM_CC_43241_CHIP_ID; devinfo->bus_pub.chiprev = chiprev; } if (chipid == BRCMF_POSTBOOT_ID) { @@ -1474,7 +1499,7 @@ brcmf_usb_prepare_fw_request(struct brcmf_usbdev_info *devinfo) }; char hsic_base[BRCMF_FW_NAME_LEN]; struct brcmf_firmware_mapping hsic_fwnames[] = { - { BRCM_CC_43241_CHIP_ID, 0xFFFFFFFF, hsic_base }, + { devinfo->bus_pub.devid, 0xFFFFFFFF, hsic_base }, }; bool hsic = brcmf_usb_is_hsic(devinfo); @@ -1485,7 +1510,8 @@ brcmf_usb_prepare_fw_request(struct brcmf_usbdev_info *devinfo) return NULL; if (strstarts(board, "apple,")) board += strlen("apple,"); - snprintf(hsic_base, sizeof(hsic_base), BRCMF_USB_HSIC_FW_FMT, board); + snprintf(hsic_base, sizeof(hsic_base), BRCMF_USB_HSIC_FW_FMT, + devinfo->hsic_chip ? devinfo->hsic_chip->name : "43241", board); } fwreq = brcmf_fw_alloc_request(devinfo->bus_pub.devid, devinfo->bus_pub.chiprev, @@ -1621,7 +1647,8 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) u8 endpoint_num, ep; if (le16_to_cpu(usb->descriptor.idVendor) == BRCM_USB_VENDOR_ID_BROADCOM && - le16_to_cpu(usb->descriptor.idProduct) == BRCM_USB_APPLE_HSIC_DEVICE_ID && + (le16_to_cpu(usb->descriptor.idProduct) == BRCM_USB_APPLE_HSIC_DEVICE_ID || + le16_to_cpu(usb->descriptor.idProduct) == BRCM_USB_APPLE_HSIC_43342_DEVICE_ID) && (!brcmf_usb_hsic_radio(usb) || !hsic_bind)) return -ENODEV; if (!id) { @@ -1831,6 +1858,7 @@ static const struct usb_device_id brcmf_usb_devid_table[] = { BRCMF_USB_DEVICE(BRCM_USB_43242_DEVICE_ID), BRCMF_USB_DEVICE(BRCM_USB_43569_DEVICE_ID), BRCMF_USB_DEVICE(BRCM_USB_APPLE_HSIC_DEVICE_ID), /* Cascadia */ + BRCMF_USB_DEVICE(BRCM_USB_APPLE_HSIC_43342_DEVICE_ID), /* iPhone 5s */ LINKSYS_USB_DEVICE(BRCM_USB_43235_LINKSYS_DEVICE_ID), CYPRESS_USB_DEVICE(CY_USB_4373_DEVICE_ID), { USB_DEVICE(BRCM_USB_VENDOR_ID_LG, BRCM_USB_43242_LG_DEVICE_ID) }, diff --git a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h index 91ac4371c90d52..2198a27241e4e1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h @@ -27,6 +27,7 @@ #define BRCM_CC_4334_CHIP_ID 0x4334 #define BRCM_CC_43340_CHIP_ID 43340 #define BRCM_CC_43341_CHIP_ID 43341 +#define BRCM_CC_43342_CHIP_ID 43342 #define BRCM_CC_43362_CHIP_ID 43362 #define BRCM_CC_4335_CHIP_ID 0x4335 #define BRCM_CC_4339_CHIP_ID 0x4339 diff --git a/drivers/regulator/apple-pmic-touch-regulator.c b/drivers/regulator/apple-pmic-touch-regulator.c index ad426a9ddeb179..a6dca7be96738c 100644 --- a/drivers/regulator/apple-pmic-touch-regulator.c +++ b/drivers/regulator/apple-pmic-touch-regulator.c @@ -147,6 +147,23 @@ static const struct regulator_desc apple_august_touch_analog = { .disable_val = 0, }; +/* + * Amber (D2045, A7 iPhone 5s) pmuL(0x20e): LDO index 14. In iOS 12.5.8 + * (16H88), AppleD2045PMU::_setLDO at 0xfffffff008441950 indexes 12-byte + * entries at 0xfffffff0070aa494; entry 14 enables with register 0x85 bit 1 + * (read/modify/write), an enable-only switch with no voltage field. + */ +static const struct regulator_desc apple_amber_touch_core = { + .name = "amber-touch-core", + .ops = &apple_pmic_touch_regulator_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .enable_reg = 0x85, + .enable_mask = 0x02, + .enable_val = 0x02, + .disable_val = 0, +}; + static const struct regulator_desc apple_d2186_touch_core = { .name = "d2186-touch-core", .ops = &apple_pmic_touch_regulator_ops, @@ -455,6 +472,10 @@ static const struct of_device_id apple_pmic_touch_regulator_of_match[] = { .compatible = "apple,august-touch-analog-regulator", .data = &apple_august_touch_analog, }, + { + .compatible = "apple,amber-touch-core-regulator", + .data = &apple_amber_touch_core, + }, { .compatible = "apple,d2186-touch-core-regulator", .data = &apple_d2186_touch_core, diff --git a/drivers/usb/host/apple-a7-wlan.c b/drivers/usb/host/apple-a7-wlan.c index 8542168c76ae08..f1ec03dedba3c7 100644 --- a/drivers/usb/host/apple-a7-wlan.c +++ b/drivers/usb/host/apple-a7-wlan.c @@ -45,7 +45,14 @@ #define PMGR_BASE 0x20e000000ULL #define USB_COMPLEX 0x20c900000ULL /* ADT usb-complex reg, usb_widget at +1c/3c/5c/7c */ #define GPIO_BASE 0x20e300000ULL -#define PMU_GPIO3 0x403 /* D2089 GPIO3 configuration: radio reset */ +/* The iPads' radio reset: D2089 (pmic@3c) GPIO3. A board names another with + * apple,pmu-reset = <&pmic LINE>; Apple's D2045 and D2089 drivers both + * configure GPIO n at register 0x400 | n (n <= 15). + */ +#define PMU_GPIO_BASE 0x400 +#define PMU_GPIO_LINES 16 +#define J72_PMU_PATH "/soc/i2c@20a110000/pmic@3c" +#define J72_PMU_LINE 3 /* The BCM43241 boot ROM: AppleBCMWLANBusInterfaceHSICShim's "4324" personality */ #define RADIO_PID 0xbd1c @@ -74,6 +81,9 @@ struct a7_wlan_board { unsigned int port; /* EHCI root port of the radio */ u32 host_ready_gpio, device_ready_gpio; u16 usb_pid; /* 0a5c:xxxx boot ROM identity */ + u32 rom_chip; /* the boot ROM's chip ID (apple,rom-chip) */ + struct device_node *pmu_np; /* the PMIC holding the radio reset */ + u32 pmu_reg; /* its GPIO configuration register */ }; static struct a7_wlan_board radio; @@ -192,21 +202,18 @@ static int ready_window(void __iomem *gpio, u32 expected_host, u32 *samples, u32 static int exact_pmic(struct device *dev, const void *expected) { struct i2c_client *client = i2c_verify_client(dev); - return client && client->addr == 0x3c && dev->of_node == expected && - of_device_is_compatible(dev->of_node, "apple,anya-pmic"); + return client && dev->of_node == expected && + of_device_is_compatible(dev->of_node, "apple,i2c-pmic"); } static int acquire_pmu(void) { - struct device_node *node = of_find_node_by_path("/soc/i2c@20a110000/pmic@3c"); - if (!node) return -ENODEV; - pmic = bus_find_device(&i2c_bus_type, NULL, node, exact_pmic); - of_node_put(node); + pmic = bus_find_device(&i2c_bus_type, NULL, board->pmu_np, exact_pmic); if (!pmic) return -ENODEV; pmu_map = dev_get_regmap(pmic, NULL); if (!pmic->driver || !pmu_map || regmap_get_val_bytes(pmu_map) != 1) return -ENODEV; - return regmap_read_bypassed(pmu_map, PMU_GPIO3, &pmu_before); + return regmap_read_bypassed(pmu_map, board->pmu_reg, &pmu_before); } module_param(confirm_native, bool, 0400); @@ -376,9 +383,9 @@ static bool rom_identity_ok(void) if (rom_result || radio_vid != 0x0a5c || radio_pid != board->usb_pid) return false; /* The ADT names the chipset ('wifi-chipset' 4324); the rest is J72's. */ - if (rom_words[0] != J72_ROM_CHIP) { - pr_warn(DRV_NAME ": %s ROM chip %04x is not the ADT 4324\n", - board->name, rom_words[0]); + if (rom_words[0] != board->rom_chip) { + pr_warn(DRV_NAME ": %s ROM chip %04x is not the device tree's %04x\n", + board->name, rom_words[0], board->rom_chip); return false; } observe("ROM revision", rom_words[1], J72_ROM_REV); @@ -428,7 +435,31 @@ static int radio_from_dt(void) radio.phy_base = phy_res.start; radio.ehci_base = ehci_res.start; radio.ehci_irq = cell[1]; + /* The boot ROM's USB product ID: bd1c on the iPads, bd21 on the 5s. */ radio.usb_pid = RADIO_PID; + if (!of_property_read_u32(node, "apple,usb-pid", &cell[0])) { + if (!cell[0] || cell[0] > 0xffff) + goto out; + radio.usb_pid = cell[0]; + } + /* The ADT's 'wifi-chipset': 4324 on the iPads, 43342 on the iPhone 5s. */ + radio.rom_chip = J72_ROM_CHIP; + of_property_read_u32(node, "apple,rom-chip", &radio.rom_chip); + if (of_property_present(node, "apple,pmu-reset")) { + struct of_phandle_args reset; + + if (of_parse_phandle_with_fixed_args(node, "apple,pmu-reset", 1, 0, &reset)) + goto out; + radio.pmu_np = reset.np; + if (reset.args[0] >= PMU_GPIO_LINES) + goto out; + radio.pmu_reg = PMU_GPIO_BASE | reset.args[0]; + } else { + radio.pmu_np = of_find_node_by_path(J72_PMU_PATH); + radio.pmu_reg = PMU_GPIO_BASE | J72_PMU_LINE; + } + if (!radio.pmu_np) + goto out; ret = 0; out: of_node_put(node); @@ -545,7 +576,7 @@ static int __init observer_init(void) host_ready_before = host_ready_reg(gpio); device_ready_before = readl(gpio + board->device_ready_gpio * 4); /* The reset write 0b is only known from the 09 baseline. */ - if (!gate("PMU GPIO3", pmu_before, J72_PMU_RESET) || + if (!gate("PMU reset", pmu_before, J72_PMU_RESET) || !observe("HOST_READY config", host_ready_before, J72_HOST_READY_CFG) || !observe("DEVICE_READY config", device_ready_before & ~1U, J72_DEVICE_READY_CFG)) { result = -EPROTO; @@ -618,9 +649,9 @@ static int __init observer_init(void) /* Known full byte avoids consulting a potentially cached RMW value. * Exact native function yields0b from our required raw baseline09. */ - result = regmap_write(pmu_map, PMU_GPIO3, 0x0b); + result = regmap_write(pmu_map, board->pmu_reg, 0x0b); if (result) goto cleanup; - result = regmap_read_bypassed(pmu_map, PMU_GPIO3, &pmu_released); + result = regmap_read_bypassed(pmu_map, board->pmu_reg, &pmu_released); if (result) goto cleanup; if (pmu_released != 0x0b) { result = -EIO; @@ -704,8 +735,8 @@ static int cleanup_session(void) goto out; } if (reset_touched) { - int reset_ret = regmap_write(pmu_map, PMU_GPIO3, pmu_before); - int read_ret = regmap_read_bypassed(pmu_map, PMU_GPIO3, &pmu_after); + int reset_ret = regmap_write(pmu_map, board->pmu_reg, pmu_before); + int read_ret = regmap_read_bypassed(pmu_map, board->pmu_reg, &pmu_after); reset_restored = !reset_ret && !read_ret && pmu_after == pmu_before; if (!reset_restored) { result = -EIO;