Skip to content

Commit 757541d

Browse files
Wren6991popcornmix
authored andcommitted
Add SMI driver
Signed-off-by: Luke Wren <[email protected]> MISC: bcm2835: smi: use clock manager and fix reload issues Use clock manager instead of self-made clockmanager. Also fix some error paths that showd up during development (especially missing release of dma resources on rmmod) Signed-off-by: Martin Sperl <[email protected]> bcm2835_smi: re-add dereference to fix DMA transfers bcm2835_smi_dev: Fix handling of word-odd lengths The read and write functions did not use the correct pointer offset when dealing with an odd number of bytes after a DMA transfer. Also, only handle the remaining odd bytes if the DMA transfer completed successfully. Submitted-by: @madimario (GitHub) Signed-off-by: Phil Elwell <[email protected]> misc: bcm2835_smi: Use proper enum types for dma_{,un}map_single() Clang warns: drivers/misc/bcm2835_smi.c:692:4: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion] DMA_MEM_TO_DEV); ^~~~~~~~~~~~~~~ ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single' #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0) ~~~~~~~~~~~~~~~~~~~~ ^ drivers/misc/bcm2835_smi.c:705:35: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion] (inst->dev, phy_addr, n_bytes, DMA_MEM_TO_DEV); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single' #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0) ~~~~~~~~~~~~~~~~~~~~~~ ^ drivers/misc/bcm2835_smi.c:751:12: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion] DMA_DEV_TO_MEM); ^~~~~~~~~~~~~~~ ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single' #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0) ~~~~~~~~~~~~~~~~~~~~ ^ drivers/misc/bcm2835_smi.c:761:50: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion] dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_DEV_TO_MEM); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single' #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0) ~~~~~~~~~~~~~~~~~~~~~~ ^ 4 warnings generated. Use the proper enumerated type to clear up the warning. There is not actually a bug here because the enumerated types have the same integer value: DMA_MEM_TO_DEV = DMA_TO_DEVICE = 1 DMA_DEV_TO_MEM = DMA_FROM_DEVICE = 2 Fixes: 93254d0 ("Add SMI driver") Signed-off-by: Nathan Chancellor <[email protected]> bcm2835-smi: Use phys addresses for slave DMA config Contrary to what struct snd_dmaengine_dai_dma_data suggests, the configuration of addresses of DMA slave interfaces should be done in CPU physical addresses. Signed-off-by: Phil Elwell <[email protected]>
1 parent 3c104ad commit 757541d

File tree

9 files changed

+1835
-0
lines changed

9 files changed

+1835
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
* Broadcom BCM2835 SMI character device driver.
2+
3+
SMI or secondary memory interface is a peripheral specific to certain Broadcom
4+
SOCs, and is helpful for talking to things like parallel-interface displays
5+
and NAND flashes (in fact, most things with a parallel register interface).
6+
7+
This driver adds a character device which provides a user-space interface to
8+
an instance of the SMI driver.
9+
10+
Required properties:
11+
- compatible: "brcm,bcm2835-smi-dev"
12+
- smi_handle: a phandle to the smi node.
13+
14+
Optional properties:
15+
- None.
16+
17+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
* Broadcom BCM2835 SMI driver.
2+
3+
SMI or secondary memory interface is a peripheral specific to certain Broadcom
4+
SOCs, and is helpful for talking to things like parallel-interface displays
5+
and NAND flashes (in fact, most things with a parallel register interface).
6+
7+
Required properties:
8+
- compatible: "brcm,bcm2835-smi"
9+
- reg: Should contain location and length of SMI registers and SMI clkman regs
10+
- interrupts: *the* SMI interrupt.
11+
- pinctrl-names: should be "default".
12+
- pinctrl-0: the phandle of the gpio pin node.
13+
- brcm,smi-clock-source: the clock source for clkman
14+
- brcm,smi-clock-divisor: the integer clock divisor for clkman
15+
- dmas: the dma controller phandle and the DREQ number (4 on a 2835)
16+
- dma-names: the name used by the driver to request its channel.
17+
Should be "rx-tx".
18+
19+
Optional properties:
20+
- None.
21+
22+
Examples:
23+
24+
8 data pin configuration:
25+
26+
smi: smi@7e600000 {
27+
compatible = "brcm,bcm2835-smi";
28+
reg = <0x7e600000 0x44>, <0x7e1010b0 0x8>;
29+
interrupts = <2 16>;
30+
pinctrl-names = "default";
31+
pinctrl-0 = <&smi_pins>;
32+
brcm,smi-clock-source = <6>;
33+
brcm,smi-clock-divisor = <4>;
34+
dmas = <&dma 4>;
35+
dma-names = "rx-tx";
36+
37+
status = "okay";
38+
};
39+
40+
smi_pins: smi_pins {
41+
brcm,pins = <2 3 4 5 6 7 8 9 10 11 12 13 14 15>;
42+
/* Alt 1: SMI */
43+
brcm,function = <5 5 5 5 5 5 5 5 5 5 5 5 5 5>;
44+
/* /CS, /WE and /OE are pulled high, as they are
45+
generally active low signals */
46+
brcm,pull = <2 2 2 2 2 2 0 0 0 0 0 0 0 0>;
47+
};
48+

drivers/char/broadcom/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ config BCM2708_VCMEM
1616
Helper for videocore memory access and total size allocation.
1717

1818
endif
19+
20+
config BCM2835_SMI_DEV
21+
tristate "Character device driver for BCM2835 Secondary Memory Interface"
22+
depends on BCM2835_SMI
23+
default m
24+
help
25+
This driver provides a character device interface (ioctl + read/write) to
26+
Broadcom's Secondary Memory interface. The low-level functionality is provided
27+
by the SMI driver itself.

drivers/char/broadcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
2+
obj-$(CONFIG_BCM2835_SMI_DEV) += bcm2835_smi_dev.o

0 commit comments

Comments
 (0)