Skip to content

Commit c25b707

Browse files
committed
Merge branch 'bits/170-atcphy' into asahi-wip
2 parents cfa699a + 50794a6 commit c25b707

12 files changed

Lines changed: 3567 additions & 23 deletions

File tree

drivers/nvmem/core.c

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

566566
if (cell->nbits)
567-
cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
568-
BITS_PER_BYTE);
567+
cell->bytes = round_up(DIV_ROUND_UP(cell->nbits + cell->bit_offset,
568+
BITS_PER_BYTE), nvmem->word_size);
569569

570570
if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
571571
dev_err(&nvmem->dev,
@@ -806,11 +806,6 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod
806806
if (addr && len == (2 * sizeof(u32))) {
807807
info.bit_offset = be32_to_cpup(addr++);
808808
info.nbits = be32_to_cpup(addr);
809-
if (info.bit_offset >= BITS_PER_BYTE || info.nbits < 1) {
810-
dev_err(dev, "nvmem: invalid bits on %pOF\n", child);
811-
of_node_put(child);
812-
return -EINVAL;
813-
}
814809
}
815810

816811
info.np = of_node_get(child);
@@ -1599,15 +1594,23 @@ EXPORT_SYMBOL_GPL(nvmem_cell_put);
15991594
static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf)
16001595
{
16011596
u8 *p, *b;
1602-
int i, extra, bit_offset = cell->bit_offset;
1597+
int i, padding, extra, bit_offset = cell->bit_offset;
1598+
int bytes = cell->bytes;
16031599

16041600
p = b = buf;
16051601
if (bit_offset) {
1602+
padding = bit_offset/8;
1603+
if (padding) {
1604+
memmove(buf, buf + padding, bytes - padding);
1605+
bit_offset -= BITS_PER_BYTE * padding;
1606+
bytes -= padding;
1607+
}
1608+
16061609
/* First shift */
16071610
*b++ >>= bit_offset;
16081611

16091612
/* setup rest of the bytes if any */
1610-
for (i = 1; i < cell->bytes; i++) {
1613+
for (i = 1; i < bytes; i++) {
16111614
/* Get bits from next byte and shift them towards msb */
16121615
*p |= *b << (BITS_PER_BYTE - bit_offset);
16131616

@@ -1620,7 +1623,7 @@ static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void
16201623
}
16211624

16221625
/* result fits in less bytes */
1623-
extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE);
1626+
extra = bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE);
16241627
while (--extra >= 0)
16251628
*p-- = 0;
16261629

drivers/phy/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ config PHY_CAN_TRANSCEIVER
7474

7575
source "drivers/phy/allwinner/Kconfig"
7676
source "drivers/phy/amlogic/Kconfig"
77+
source "drivers/phy/apple/Kconfig"
7778
source "drivers/phy/broadcom/Kconfig"
7879
source "drivers/phy/cadence/Kconfig"
7980
source "drivers/phy/freescale/Kconfig"

drivers/phy/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
1212
obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o
1313
obj-y += allwinner/ \
1414
amlogic/ \
15+
apple/ \
1516
broadcom/ \
1617
cadence/ \
1718
freescale/ \

drivers/phy/apple/Kconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
select TYPEC
8+
help
9+
Enable this to add support for the Apple Type-C PHY, switch
10+
and mux found in Apple SoCs such as the M1.
11+
This driver currently provides support for USB2 and USB3.
12+
13+
config PHY_APPLE_DPTX
14+
tristate "Apple DPTX PHY"
15+
depends on ARCH_APPLE || COMPILE_TEST
16+
default ARCH_APPLE
17+
select GENERIC_PHY
18+
help
19+
Enable this to add support for the Apple DPTX PHY found on Apple SoCs
20+
such as the M2.
21+
This driver provides support for DisplayPort and is used on the
22+
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)