Skip to content

Commit 4a2ce75

Browse files
committed
Merge branch 'bits/170-atcphy' into asahi-wip
2 parents fd42227 + 819ac8e commit 4a2ce75

File tree

12 files changed

+3568
-23
lines changed

12 files changed

+3568
-23
lines changed

drivers/nvmem/core.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
582582
cell->np = info->np;
583583

584584
if (cell->nbits)
585-
cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
586-
BITS_PER_BYTE);
585+
cell->bytes = round_up(DIV_ROUND_UP(cell->nbits + cell->bit_offset,
586+
BITS_PER_BYTE), nvmem->word_size);
587587

588588
if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
589589
dev_err(&nvmem->dev,
@@ -824,11 +824,6 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod
824824
if (addr && len == (2 * sizeof(u32))) {
825825
info.bit_offset = be32_to_cpup(addr++);
826826
info.nbits = be32_to_cpup(addr);
827-
if (info.bit_offset >= BITS_PER_BYTE || info.nbits < 1) {
828-
dev_err(dev, "nvmem: invalid bits on %pOF\n", child);
829-
of_node_put(child);
830-
return -EINVAL;
831-
}
832827
}
833828

834829
info.np = of_node_get(child);
@@ -1617,15 +1612,23 @@ EXPORT_SYMBOL_GPL(nvmem_cell_put);
16171612
static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf)
16181613
{
16191614
u8 *p, *b;
1620-
int i, extra, bit_offset = cell->bit_offset;
1615+
int i, padding, extra, bit_offset = cell->bit_offset;
1616+
int bytes = cell->bytes;
16211617

16221618
p = b = buf;
16231619
if (bit_offset) {
1620+
padding = bit_offset/8;
1621+
if (padding) {
1622+
memmove(buf, buf + padding, bytes - padding);
1623+
bit_offset -= BITS_PER_BYTE * padding;
1624+
bytes -= padding;
1625+
}
1626+
16241627
/* First shift */
16251628
*b++ >>= bit_offset;
16261629

16271630
/* setup rest of the bytes if any */
1628-
for (i = 1; i < cell->bytes; i++) {
1631+
for (i = 1; i < bytes; i++) {
16291632
/* Get bits from next byte and shift them towards msb */
16301633
*p |= *b << (BITS_PER_BYTE - bit_offset);
16311634

@@ -1638,7 +1641,7 @@ static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void
16381641
}
16391642

16401643
/* result fits in less bytes */
1641-
extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE);
1644+
extra = bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE);
16421645
while (--extra >= 0)
16431646
*p-- = 0;
16441647

drivers/phy/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ config PHY_AIROHA_PCIE
8484

8585
source "drivers/phy/allwinner/Kconfig"
8686
source "drivers/phy/amlogic/Kconfig"
87+
source "drivers/phy/apple/Kconfig"
8788
source "drivers/phy/broadcom/Kconfig"
8889
source "drivers/phy/cadence/Kconfig"
8990
source "drivers/phy/freescale/Kconfig"

drivers/phy/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o
1313
obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o
1414
obj-y += allwinner/ \
1515
amlogic/ \
16+
apple/ \
1617
broadcom/ \
1718
cadence/ \
1819
freescale/ \

drivers/phy/apple/Kconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
2+
config PHY_APPLE_ATC
3+
tristate "Apple Type-C PHY"
4+
depends on ARCH_APPLE || COMPILE_TEST
5+
default ARCH_APPLE
6+
select GENERIC_PHY
7+
depends on USB_SUPPORT
8+
depends on TYPEC
9+
help
10+
Enable this to add support for the Apple Type-C PHY, switch
11+
and mux found in Apple SoCs such as the M1.
12+
This driver currently provides support for USB2 and USB3.
13+
14+
config PHY_APPLE_DPTX
15+
tristate "Apple DPTX PHY"
16+
depends on ARCH_APPLE || COMPILE_TEST
17+
default ARCH_APPLE
18+
select GENERIC_PHY
19+
help
20+
Enable this to add support for the Apple DPTX PHY found on Apple SoCs
21+
such as the M2.
22+
This driver provides support for DisplayPort and is used on the
23+
Mac mini (M2, 2023).

drivers/phy/apple/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
2+
CFLAGS_trace.o := -I$(src)
3+
4+
obj-$(CONFIG_PHY_APPLE_ATC) += phy-apple-atc.o
5+
phy-apple-atc-y := atc.o
6+
phy-apple-atc-$(CONFIG_TRACING) += trace.o
7+
8+
obj-$(CONFIG_PHY_APPLE_DPTX) += phy-apple-dptx.o
9+
phy-apple-dptx-y += dptx.o

0 commit comments

Comments
 (0)