Skip to content

Commit 8a03d9a

Browse files
author
Linus Torvalds
committed
Merge branch 'for-linus' of git://www.atmel.no/~hskinnemoen/linux/kernel/avr32
* 'for-linus' of git://www.atmel.no/~hskinnemoen/linux/kernel/avr32: [AVR32] Use per-controller spi_board_info structures [AVR32] Warn, don't BUG if clk_disable is called too many times [AVR32] Make sure all genclocks have a parent [AVR32] Remove unnecessary sys_nfsservctl conditional [AVR32] Wire up the SysV IPC calls properly [AVR32] Define ioremap_nocache, ioport_map and ioport_unmap [AVR32] Fix prototypes for __raw_writesb and friends
2 parents f8abea8 + 41d8ca4 commit 8a03d9a

7 files changed

Lines changed: 167 additions & 58 deletions

File tree

‎arch/avr32/boards/atstk1000/atstk1002.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* published by the Free Software Foundation.
99
*/
1010
#include <linux/clk.h>
11-
#include <linux/device.h>
1211
#include <linux/etherdevice.h>
1312
#include <linux/init.h>
1413
#include <linux/kernel.h>
@@ -36,12 +35,11 @@ static struct eth_addr __initdata hw_addr[2];
3635
static struct eth_platform_data __initdata eth_data[2];
3736
extern struct lcdc_platform_data atstk1000_fb0_data;
3837

39-
static struct spi_board_info spi_board_info[] __initdata = {
38+
static struct spi_board_info spi0_board_info[] __initdata = {
4039
{
40+
/* QVGA display */
4141
.modalias = "ltv350qv",
42-
.controller_data = (void *)GPIO_PIN_PA(4),
4342
.max_speed_hz = 16000000,
44-
.bus_num = 0,
4543
.chip_select = 1,
4644
},
4745
};
@@ -149,8 +147,7 @@ static int __init atstk1002_init(void)
149147

150148
set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
151149

152-
spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
153-
at32_add_device_spi(0);
150+
at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
154151
at32_add_device_lcdc(0, &atstk1000_fb0_data);
155152

156153
return 0;

‎arch/avr32/kernel/syscall_table.S‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
* published by the Free Software Foundation.
99
*/
1010

11-
#if !defined(CONFIG_NFSD) && !defined(CONFIG_NFSD_MODULE)
12-
#define sys_nfsservctl sys_ni_syscall
13-
#endif
14-
15-
#if !defined(CONFIG_SYSV_IPC)
16-
# define sys_ipc sys_ni_syscall
17-
#endif
18-
1911
.section .rodata,"a",@progbits
2012
.type sys_call_table,@object
2113
.global sys_call_table
@@ -129,7 +121,7 @@ sys_call_table:
129121
.long sys_getitimer /* 105 */
130122
.long sys_swapoff
131123
.long sys_sysinfo
132-
.long sys_ipc
124+
.long sys_ni_syscall /* was sys_ipc briefly */
133125
.long sys_sendfile
134126
.long sys_setdomainname /* 110 */
135127
.long sys_newuname
@@ -287,4 +279,16 @@ sys_call_table:
287279
.long sys_tee
288280
.long sys_vmsplice
289281
.long __sys_epoll_pwait /* 265 */
282+
.long sys_msgget
283+
.long sys_msgsnd
284+
.long sys_msgrcv
285+
.long sys_msgctl
286+
.long sys_semget /* 270 */
287+
.long sys_semop
288+
.long sys_semctl
289+
.long sys_semtimedop
290+
.long sys_shmat
291+
.long sys_shmget /* 275 */
292+
.long sys_shmdt
293+
.long sys_shmctl
290294
.long sys_ni_syscall /* r8 is saturated at nr_syscalls */

‎arch/avr32/mach-at32ap/at32ap7000.c‎

Lines changed: 111 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/clk.h>
99
#include <linux/init.h>
1010
#include <linux/platform_device.h>
11+
#include <linux/spi/spi.h>
1112

1213
#include <asm/io.h>
1314

@@ -310,8 +311,6 @@ static void genclk_mode(struct clk *clk, int enabled)
310311
{
311312
u32 control;
312313

313-
BUG_ON(clk->index > 7);
314-
315314
control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
316315
if (enabled)
317316
control |= SM_BIT(CEN);
@@ -325,11 +324,6 @@ static unsigned long genclk_get_rate(struct clk *clk)
325324
u32 control;
326325
unsigned long div = 1;
327326

328-
BUG_ON(clk->index > 7);
329-
330-
if (!clk->parent)
331-
return 0;
332-
333327
control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
334328
if (control & SM_BIT(DIVEN))
335329
div = 2 * (SM_BFEXT(DIV, control) + 1);
@@ -342,11 +336,6 @@ static long genclk_set_rate(struct clk *clk, unsigned long rate, int apply)
342336
u32 control;
343337
unsigned long parent_rate, actual_rate, div;
344338

345-
BUG_ON(clk->index > 7);
346-
347-
if (!clk->parent)
348-
return 0;
349-
350339
parent_rate = clk->parent->get_rate(clk->parent);
351340
control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
352341

@@ -373,11 +362,8 @@ int genclk_set_parent(struct clk *clk, struct clk *parent)
373362
{
374363
u32 control;
375364

376-
BUG_ON(clk->index > 7);
377-
378365
printk("clk %s: new parent %s (was %s)\n",
379-
clk->name, parent->name,
380-
clk->parent ? clk->parent->name : "(null)");
366+
clk->name, parent->name, clk->parent->name);
381367

382368
control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
383369

@@ -399,6 +385,22 @@ int genclk_set_parent(struct clk *clk, struct clk *parent)
399385
return 0;
400386
}
401387

388+
static void __init genclk_init_parent(struct clk *clk)
389+
{
390+
u32 control;
391+
struct clk *parent;
392+
393+
BUG_ON(clk->index > 7);
394+
395+
control = sm_readl(&system_manager, PM_GCCTRL + 4 * clk->index);
396+
if (control & SM_BIT(OSCSEL))
397+
parent = (control & SM_BIT(PLLSEL)) ? &pll1 : &osc1;
398+
else
399+
parent = (control & SM_BIT(PLLSEL)) ? &pll0 : &osc0;
400+
401+
clk->parent = parent;
402+
}
403+
402404
/* --------------------------------------------------------------------
403405
* System peripherals
404406
* -------------------------------------------------------------------- */
@@ -750,8 +752,41 @@ static struct resource atmel_spi1_resource[] = {
750752
DEFINE_DEV(atmel_spi, 1);
751753
DEV_CLK(spi_clk, atmel_spi1, pba, 1);
752754

753-
struct platform_device *__init at32_add_device_spi(unsigned int id)
755+
static void
756+
at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b,
757+
unsigned int n, const u8 *pins)
758+
{
759+
unsigned int pin, mode;
760+
761+
for (; n; n--, b++) {
762+
b->bus_num = bus_num;
763+
if (b->chip_select >= 4)
764+
continue;
765+
pin = (unsigned)b->controller_data;
766+
if (!pin) {
767+
pin = pins[b->chip_select];
768+
b->controller_data = (void *)pin;
769+
}
770+
mode = AT32_GPIOF_OUTPUT;
771+
if (!(b->mode & SPI_CS_HIGH))
772+
mode |= AT32_GPIOF_HIGH;
773+
at32_select_gpio(pin, mode);
774+
}
775+
}
776+
777+
struct platform_device *__init
778+
at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
754779
{
780+
/*
781+
* Manage the chipselects as GPIOs, normally using the same pins
782+
* the SPI controller expects; but boards can use other pins.
783+
*/
784+
static u8 __initdata spi0_pins[] =
785+
{ GPIO_PIN_PA(3), GPIO_PIN_PA(4),
786+
GPIO_PIN_PA(5), GPIO_PIN_PA(20), };
787+
static u8 __initdata spi1_pins[] =
788+
{ GPIO_PIN_PB(2), GPIO_PIN_PB(3),
789+
GPIO_PIN_PB(4), GPIO_PIN_PA(27), };
755790
struct platform_device *pdev;
756791

757792
switch (id) {
@@ -760,35 +795,22 @@ struct platform_device *__init at32_add_device_spi(unsigned int id)
760795
select_peripheral(PA(0), PERIPH_A, 0); /* MISO */
761796
select_peripheral(PA(1), PERIPH_A, 0); /* MOSI */
762797
select_peripheral(PA(2), PERIPH_A, 0); /* SCK */
763-
764-
/* NPCS[2:0] */
765-
at32_select_gpio(GPIO_PIN_PA(3),
766-
AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
767-
at32_select_gpio(GPIO_PIN_PA(4),
768-
AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
769-
at32_select_gpio(GPIO_PIN_PA(5),
770-
AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
798+
at32_spi_setup_slaves(0, b, n, spi0_pins);
771799
break;
772800

773801
case 1:
774802
pdev = &atmel_spi1_device;
775803
select_peripheral(PB(0), PERIPH_B, 0); /* MISO */
776804
select_peripheral(PB(1), PERIPH_B, 0); /* MOSI */
777805
select_peripheral(PB(5), PERIPH_B, 0); /* SCK */
778-
779-
/* NPCS[2:0] */
780-
at32_select_gpio(GPIO_PIN_PB(2),
781-
AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
782-
at32_select_gpio(GPIO_PIN_PB(3),
783-
AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
784-
at32_select_gpio(GPIO_PIN_PB(4),
785-
AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
806+
at32_spi_setup_slaves(1, b, n, spi1_pins);
786807
break;
787808

788809
default:
789810
return NULL;
790811
}
791812

813+
spi_register_board_info(b, n);
792814
platform_device_register(pdev);
793815
return pdev;
794816
}
@@ -872,6 +894,50 @@ at32_add_device_lcdc(unsigned int id, struct lcdc_platform_data *data)
872894
return pdev;
873895
}
874896

897+
/* --------------------------------------------------------------------
898+
* GCLK
899+
* -------------------------------------------------------------------- */
900+
static struct clk gclk0 = {
901+
.name = "gclk0",
902+
.mode = genclk_mode,
903+
.get_rate = genclk_get_rate,
904+
.set_rate = genclk_set_rate,
905+
.set_parent = genclk_set_parent,
906+
.index = 0,
907+
};
908+
static struct clk gclk1 = {
909+
.name = "gclk1",
910+
.mode = genclk_mode,
911+
.get_rate = genclk_get_rate,
912+
.set_rate = genclk_set_rate,
913+
.set_parent = genclk_set_parent,
914+
.index = 1,
915+
};
916+
static struct clk gclk2 = {
917+
.name = "gclk2",
918+
.mode = genclk_mode,
919+
.get_rate = genclk_get_rate,
920+
.set_rate = genclk_set_rate,
921+
.set_parent = genclk_set_parent,
922+
.index = 2,
923+
};
924+
static struct clk gclk3 = {
925+
.name = "gclk3",
926+
.mode = genclk_mode,
927+
.get_rate = genclk_get_rate,
928+
.set_rate = genclk_set_rate,
929+
.set_parent = genclk_set_parent,
930+
.index = 3,
931+
};
932+
static struct clk gclk4 = {
933+
.name = "gclk4",
934+
.mode = genclk_mode,
935+
.get_rate = genclk_get_rate,
936+
.set_rate = genclk_set_rate,
937+
.set_parent = genclk_set_parent,
938+
.index = 4,
939+
};
940+
875941
struct clk *at32_clock_list[] = {
876942
&osc32k,
877943
&osc0,
@@ -908,6 +974,11 @@ struct clk *at32_clock_list[] = {
908974
&atmel_spi1_spi_clk,
909975
&lcdc0_hclk,
910976
&lcdc0_pixclk,
977+
&gclk0,
978+
&gclk1,
979+
&gclk2,
980+
&gclk3,
981+
&gclk4,
911982
};
912983
unsigned int at32_nr_clocks = ARRAY_SIZE(at32_clock_list);
913984

@@ -936,6 +1007,13 @@ void __init at32_clock_init(void)
9361007
if (sm_readl(sm, PM_PLL1) & SM_BIT(PLLOSC))
9371008
pll1.parent = &osc1;
9381009

1010+
genclk_init_parent(&gclk0);
1011+
genclk_init_parent(&gclk1);
1012+
genclk_init_parent(&gclk2);
1013+
genclk_init_parent(&gclk3);
1014+
genclk_init_parent(&gclk4);
1015+
genclk_init_parent(&lcdc0_pixclk);
1016+
9391017
/*
9401018
* Turn on all clocks that have at least one user already, and
9411019
* turn off everything else. We only do this for module

‎arch/avr32/mach-at32ap/clock.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ EXPORT_SYMBOL(clk_enable);
6363

6464
static void __clk_disable(struct clk *clk)
6565
{
66-
BUG_ON(clk->users == 0);
66+
if (clk->users == 0) {
67+
printk(KERN_ERR "%s: mismatched disable\n", clk->name);
68+
WARN_ON(1);
69+
return;
70+
}
6771

6872
if (--clk->users == 0 && clk->mode)
6973
clk->mode(clk, 0);

‎include/asm-avr32/arch-at32ap/board.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ struct eth_platform_data {
2626
struct platform_device *
2727
at32_add_device_eth(unsigned int id, struct eth_platform_data *data);
2828

29-
struct platform_device *at32_add_device_spi(unsigned int id);
29+
struct spi_board_info;
30+
struct platform_device *
31+
at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n);
3032

3133
struct lcdc_platform_data {
3234
unsigned long fbmem_start;

‎include/asm-avr32/io.h‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ static __inline__ void * phys_to_virt(unsigned long address)
2828
* Generic IO read/write. These perform native-endian accesses. Note
2929
* that some architectures will want to re-define __raw_{read,write}w.
3030
*/
31-
extern void __raw_writesb(unsigned int addr, const void *data, int bytelen);
32-
extern void __raw_writesw(unsigned int addr, const void *data, int wordlen);
33-
extern void __raw_writesl(unsigned int addr, const void *data, int longlen);
31+
extern void __raw_writesb(void __iomem *addr, const void *data, int bytelen);
32+
extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen);
33+
extern void __raw_writesl(void __iomem *addr, const void *data, int longlen);
3434

35-
extern void __raw_readsb(unsigned int addr, void *data, int bytelen);
36-
extern void __raw_readsw(unsigned int addr, void *data, int wordlen);
37-
extern void __raw_readsl(unsigned int addr, void *data, int longlen);
35+
extern void __raw_readsb(const void __iomem *addr, void *data, int bytelen);
36+
extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen);
37+
extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
3838

3939
static inline void writeb(unsigned char b, volatile void __iomem *addr)
4040
{
@@ -252,6 +252,9 @@ extern void __iounmap(void __iomem *addr);
252252
#define ioremap(offset, size) \
253253
__ioremap((offset), (size), 0)
254254

255+
#define ioremap_nocache(offset, size) \
256+
__ioremap((offset), (size), 0)
257+
255258
#define iounmap(addr) \
256259
__iounmap(addr)
257260

@@ -263,6 +266,14 @@ extern void __iounmap(void __iomem *addr);
263266
#define page_to_bus page_to_phys
264267
#define bus_to_page phys_to_page
265268

269+
/*
270+
* Create a virtual mapping cookie for an IO port range. There exists
271+
* no such thing as port-based I/O on AVR32, so a regular ioremap()
272+
* should do what we need.
273+
*/
274+
#define ioport_map(port, nr) ioremap(port, nr)
275+
#define ioport_unmap(port) iounmap(port)
276+
266277
#define dma_cache_wback_inv(_start, _size) \
267278
flush_dcache_region(_start, _size)
268279
#define dma_cache_inv(_start, _size) \

0 commit comments

Comments
 (0)