diff options
Diffstat (limited to 'arch/sparc64')
-rw-r--r-- | arch/sparc64/kernel/pci.c | 10 | ||||
-rw-r--r-- | arch/sparc64/kernel/time.c | 34 | ||||
-rw-r--r-- | arch/sparc64/lib/PeeCeeI.c | 139 |
3 files changed, 62 insertions, 121 deletions
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c index 242ac1ccae7d..bdb7c0a6d83d 100644 --- a/arch/sparc64/kernel/pci.c +++ b/arch/sparc64/kernel/pci.c | |||
@@ -889,6 +889,7 @@ static int __pci_mmap_make_offset(struct pci_dev *pdev, | |||
889 | 889 | ||
890 | for (i = 0; i <= PCI_ROM_RESOURCE; i++) { | 890 | for (i = 0; i <= PCI_ROM_RESOURCE; i++) { |
891 | struct resource *rp = &pdev->resource[i]; | 891 | struct resource *rp = &pdev->resource[i]; |
892 | resource_size_t aligned_end; | ||
892 | 893 | ||
893 | /* Active? */ | 894 | /* Active? */ |
894 | if (!rp->flags) | 895 | if (!rp->flags) |
@@ -906,8 +907,15 @@ static int __pci_mmap_make_offset(struct pci_dev *pdev, | |||
906 | continue; | 907 | continue; |
907 | } | 908 | } |
908 | 909 | ||
910 | /* Align the resource end to the next page address. | ||
911 | * PAGE_SIZE intentionally added instead of (PAGE_SIZE - 1), | ||
912 | * because actually we need the address of the next byte | ||
913 | * after rp->end. | ||
914 | */ | ||
915 | aligned_end = (rp->end + PAGE_SIZE) & PAGE_MASK; | ||
916 | |||
909 | if ((rp->start <= user_paddr) && | 917 | if ((rp->start <= user_paddr) && |
910 | (user_paddr + user_size) <= (rp->end + 1UL)) | 918 | (user_paddr + user_size) <= aligned_end) |
911 | break; | 919 | break; |
912 | } | 920 | } |
913 | 921 | ||
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 80d71a5ce1e3..141da3759091 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -490,6 +490,7 @@ static struct of_device_id __initdata bq4802_match[] = { | |||
490 | .name = "rtc", | 490 | .name = "rtc", |
491 | .compatible = "bq4802", | 491 | .compatible = "bq4802", |
492 | }, | 492 | }, |
493 | {}, | ||
493 | }; | 494 | }; |
494 | 495 | ||
495 | static struct of_platform_driver bq4802_driver = { | 496 | static struct of_platform_driver bq4802_driver = { |
@@ -503,39 +504,16 @@ static struct of_platform_driver bq4802_driver = { | |||
503 | static unsigned char mostek_read_byte(struct device *dev, u32 ofs) | 504 | static unsigned char mostek_read_byte(struct device *dev, u32 ofs) |
504 | { | 505 | { |
505 | struct platform_device *pdev = to_platform_device(dev); | 506 | struct platform_device *pdev = to_platform_device(dev); |
506 | struct m48t59_plat_data *pdata = pdev->dev.platform_data; | 507 | void __iomem *regs = (void __iomem *) pdev->resource[0].start; |
507 | void __iomem *regs; | 508 | |
508 | unsigned char val; | 509 | return readb(regs + ofs); |
509 | |||
510 | regs = (void __iomem *) pdev->resource[0].start; | ||
511 | val = readb(regs + ofs); | ||
512 | |||
513 | /* the year 0 is 1968 */ | ||
514 | if (ofs == pdata->offset + M48T59_YEAR) { | ||
515 | val += 0x68; | ||
516 | if ((val & 0xf) > 9) | ||
517 | val += 6; | ||
518 | } | ||
519 | return val; | ||
520 | } | 510 | } |
521 | 511 | ||
522 | static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) | 512 | static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) |
523 | { | 513 | { |
524 | struct platform_device *pdev = to_platform_device(dev); | 514 | struct platform_device *pdev = to_platform_device(dev); |
525 | struct m48t59_plat_data *pdata = pdev->dev.platform_data; | 515 | void __iomem *regs = (void __iomem *) pdev->resource[0].start; |
526 | void __iomem *regs; | 516 | |
527 | |||
528 | regs = (void __iomem *) pdev->resource[0].start; | ||
529 | if (ofs == pdata->offset + M48T59_YEAR) { | ||
530 | if (val < 0x68) | ||
531 | val += 0x32; | ||
532 | else | ||
533 | val -= 0x68; | ||
534 | if ((val & 0xf) > 9) | ||
535 | val += 6; | ||
536 | if ((val & 0xf0) > 0x9A) | ||
537 | val += 0x60; | ||
538 | } | ||
539 | writeb(val, regs + ofs); | 517 | writeb(val, regs + ofs); |
540 | } | 518 | } |
541 | 519 | ||
diff --git a/arch/sparc64/lib/PeeCeeI.c b/arch/sparc64/lib/PeeCeeI.c index 8b313f11bc8d..46053e6ddd7b 100644 --- a/arch/sparc64/lib/PeeCeeI.c +++ b/arch/sparc64/lib/PeeCeeI.c | |||
@@ -20,107 +20,62 @@ void outsw(unsigned long __addr, const void *src, unsigned long count) | |||
20 | { | 20 | { |
21 | void __iomem *addr = (void __iomem *) __addr; | 21 | void __iomem *addr = (void __iomem *) __addr; |
22 | 22 | ||
23 | if (count) { | 23 | while (count--) { |
24 | u16 *ps = (u16 *)src; | 24 | __raw_writew(*(u16 *)src, addr); |
25 | u32 *pi; | 25 | src += sizeof(u16); |
26 | |||
27 | if (((u64)src) & 0x2) { | ||
28 | u16 val = le16_to_cpup(ps); | ||
29 | outw(val, addr); | ||
30 | ps++; | ||
31 | count--; | ||
32 | } | ||
33 | pi = (u32 *)ps; | ||
34 | while (count >= 2) { | ||
35 | u32 w = le32_to_cpup(pi); | ||
36 | |||
37 | pi++; | ||
38 | outw(w >> 0, addr); | ||
39 | outw(w >> 16, addr); | ||
40 | count -= 2; | ||
41 | } | ||
42 | ps = (u16 *)pi; | ||
43 | if (count) { | ||
44 | u16 val = le16_to_cpup(ps); | ||
45 | outw(val, addr); | ||
46 | } | ||
47 | } | 26 | } |
48 | } | 27 | } |
49 | 28 | ||
50 | void outsl(unsigned long __addr, const void *src, unsigned long count) | 29 | void outsl(unsigned long __addr, const void *src, unsigned long count) |
51 | { | 30 | { |
52 | void __iomem *addr = (void __iomem *) __addr; | 31 | void __iomem *addr = (void __iomem *) __addr; |
32 | u32 l, l2; | ||
53 | 33 | ||
54 | if (count) { | 34 | if (!count) |
55 | if ((((u64)src) & 0x3) == 0) { | 35 | return; |
56 | u32 *p = (u32 *)src; | ||
57 | while (count--) { | ||
58 | u32 val = cpu_to_le32p(p); | ||
59 | outl(val, addr); | ||
60 | p++; | ||
61 | } | ||
62 | } else { | ||
63 | u8 *pb; | ||
64 | u16 *ps = (u16 *)src; | ||
65 | u32 l = 0, l2; | ||
66 | u32 *pi; | ||
67 | |||
68 | switch (((u64)src) & 0x3) { | ||
69 | case 0x2: | ||
70 | count -= 1; | ||
71 | l = cpu_to_le16p(ps) << 16; | ||
72 | ps++; | ||
73 | pi = (u32 *)ps; | ||
74 | while (count--) { | ||
75 | l2 = cpu_to_le32p(pi); | ||
76 | pi++; | ||
77 | outl(((l >> 16) | (l2 << 16)), addr); | ||
78 | l = l2; | ||
79 | } | ||
80 | ps = (u16 *)pi; | ||
81 | l2 = cpu_to_le16p(ps); | ||
82 | outl(((l >> 16) | (l2 << 16)), addr); | ||
83 | break; | ||
84 | |||
85 | case 0x1: | ||
86 | count -= 1; | ||
87 | pb = (u8 *)src; | ||
88 | l = (*pb++ << 8); | ||
89 | ps = (u16 *)pb; | ||
90 | l2 = cpu_to_le16p(ps); | ||
91 | ps++; | ||
92 | l |= (l2 << 16); | ||
93 | pi = (u32 *)ps; | ||
94 | while (count--) { | ||
95 | l2 = cpu_to_le32p(pi); | ||
96 | pi++; | ||
97 | outl(((l >> 8) | (l2 << 24)), addr); | ||
98 | l = l2; | ||
99 | } | ||
100 | pb = (u8 *)pi; | ||
101 | outl(((l >> 8) | (*pb << 24)), addr); | ||
102 | break; | ||
103 | 36 | ||
104 | case 0x3: | 37 | switch (((unsigned long)src) & 0x3) { |
105 | count -= 1; | 38 | case 0x0: |
106 | pb = (u8 *)src; | 39 | /* src is naturally aligned */ |
107 | l = (*pb++ << 24); | 40 | while (count--) { |
108 | pi = (u32 *)pb; | 41 | __raw_writel(*(u32 *)src, addr); |
109 | while (count--) { | 42 | src += sizeof(u32); |
110 | l2 = cpu_to_le32p(pi); | 43 | } |
111 | pi++; | 44 | break; |
112 | outl(((l >> 24) | (l2 << 8)), addr); | 45 | case 0x2: |
113 | l = l2; | 46 | /* 2-byte alignment */ |
114 | } | 47 | while (count--) { |
115 | ps = (u16 *)pi; | 48 | l = (*(u16 *)src) << 16; |
116 | l2 = cpu_to_le16p(ps); | 49 | l |= *(u16 *)(src + sizeof(u16)); |
117 | ps++; | 50 | __raw_writel(l, addr); |
118 | pb = (u8 *)ps; | 51 | src += sizeof(u32); |
119 | l2 |= (*pb << 16); | 52 | } |
120 | outl(((l >> 24) | (l2 << 8)), addr); | 53 | break; |
121 | break; | 54 | case 0x1: |
122 | } | 55 | /* Hold three bytes in l each time, grab a byte from l2 */ |
56 | l = (*(u8 *)src) << 24; | ||
57 | l |= (*(u16 *)(src + sizeof(u8))) << 8; | ||
58 | src += sizeof(u8) + sizeof(u16); | ||
59 | while (count--) { | ||
60 | l2 = *(u32 *)src; | ||
61 | l |= (l2 >> 24); | ||
62 | __raw_writel(l, addr); | ||
63 | l = l2 << 8; | ||
64 | src += sizeof(u32); | ||
65 | } | ||
66 | break; | ||
67 | case 0x3: | ||
68 | /* Hold a byte in l each time, grab 3 bytes from l2 */ | ||
69 | l = (*(u8 *)src) << 24; | ||
70 | src += sizeof(u8); | ||
71 | while (count--) { | ||
72 | l2 = *(u32 *)src; | ||
73 | l |= (l2 >> 8); | ||
74 | __raw_writel(l, addr); | ||
75 | l = l2 << 24; | ||
76 | src += sizeof(u32); | ||
123 | } | 77 | } |
78 | break; | ||
124 | } | 79 | } |
125 | } | 80 | } |
126 | 81 | ||