diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-22 13:18:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-22 13:18:06 -0400 |
commit | 21b7ef0c6c62a14bc8e1c8c0af4e1f0ba3a56d66 (patch) | |
tree | 71e53bd0464abd14d6b37c5b4487eaa438d46b65 /drivers | |
parent | 5c5d281a93e9816966b6131ccec19519dab0e103 (diff) | |
parent | b179fb8ca57590eeb0a5d6c8dc99f91773f09c73 (diff) |
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6.git
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/sbus/char/rtc.c | 103 | ||||
-rw-r--r-- | drivers/serial/sunsab.c | 16 | ||||
-rw-r--r-- | drivers/serial/sunsu.c | 11 |
3 files changed, 119 insertions, 11 deletions
diff --git a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c index bf3273eb1c8b..49d1cd99d5ac 100644 --- a/drivers/sbus/char/rtc.c +++ b/drivers/sbus/char/rtc.c | |||
@@ -28,6 +28,42 @@ | |||
28 | 28 | ||
29 | static int rtc_busy = 0; | 29 | static int rtc_busy = 0; |
30 | 30 | ||
31 | /* This is the structure layout used by drivers/char/rtc.c, we | ||
32 | * support that driver's ioctls so that things are less messy in | ||
33 | * userspace. | ||
34 | */ | ||
35 | struct rtc_time_generic { | ||
36 | int tm_sec; | ||
37 | int tm_min; | ||
38 | int tm_hour; | ||
39 | int tm_mday; | ||
40 | int tm_mon; | ||
41 | int tm_year; | ||
42 | int tm_wday; | ||
43 | int tm_yday; | ||
44 | int tm_isdst; | ||
45 | }; | ||
46 | #define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */ | ||
47 | #define RTC_AIE_OFF _IO('p', 0x02) /* ... off */ | ||
48 | #define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */ | ||
49 | #define RTC_UIE_OFF _IO('p', 0x04) /* ... off */ | ||
50 | #define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */ | ||
51 | #define RTC_PIE_OFF _IO('p', 0x06) /* ... off */ | ||
52 | #define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */ | ||
53 | #define RTC_WIE_OFF _IO('p', 0x10) /* ... off */ | ||
54 | #define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time_generic) /* Read RTC time */ | ||
55 | #define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time_generic) /* Set RTC time */ | ||
56 | #define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */ | ||
57 | #define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */ | ||
58 | #define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */ | ||
59 | #define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */ | ||
60 | #define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */ | ||
61 | #define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */ | ||
62 | #define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/ | ||
63 | #define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/ | ||
64 | #define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */ | ||
65 | #define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */ | ||
66 | |||
31 | /* Retrieve the current date and time from the real time clock. */ | 67 | /* Retrieve the current date and time from the real time clock. */ |
32 | static void get_rtc_time(struct rtc_time *t) | 68 | static void get_rtc_time(struct rtc_time *t) |
33 | { | 69 | { |
@@ -82,29 +118,87 @@ void set_rtc_time(struct rtc_time *t) | |||
82 | spin_unlock_irq(&mostek_lock); | 118 | spin_unlock_irq(&mostek_lock); |
83 | } | 119 | } |
84 | 120 | ||
121 | static int put_rtc_time_generic(void __user *argp, struct rtc_time *tm) | ||
122 | { | ||
123 | struct rtc_time_generic __user *utm = argp; | ||
124 | |||
125 | if (__put_user(tm->sec, &utm->tm_sec) || | ||
126 | __put_user(tm->min, &utm->tm_min) || | ||
127 | __put_user(tm->hour, &utm->tm_hour) || | ||
128 | __put_user(tm->dom, &utm->tm_mday) || | ||
129 | __put_user(tm->month, &utm->tm_mon) || | ||
130 | __put_user(tm->year, &utm->tm_year) || | ||
131 | __put_user(tm->dow, &utm->tm_wday) || | ||
132 | __put_user(0, &utm->tm_yday) || | ||
133 | __put_user(0, &utm->tm_isdst)) | ||
134 | return -EFAULT; | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static int get_rtc_time_generic(struct rtc_time *tm, void __user *argp) | ||
140 | { | ||
141 | struct rtc_time_generic __user *utm = argp; | ||
142 | |||
143 | if (__get_user(tm->sec, &utm->tm_sec) || | ||
144 | __get_user(tm->min, &utm->tm_min) || | ||
145 | __get_user(tm->hour, &utm->tm_hour) || | ||
146 | __get_user(tm->dom, &utm->tm_mday) || | ||
147 | __get_user(tm->month, &utm->tm_mon) || | ||
148 | __get_user(tm->year, &utm->tm_year) || | ||
149 | __get_user(tm->dow, &utm->tm_wday)) | ||
150 | return -EFAULT; | ||
151 | |||
152 | return 0; | ||
153 | } | ||
154 | |||
85 | static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 155 | static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, |
86 | unsigned long arg) | 156 | unsigned long arg) |
87 | { | 157 | { |
88 | struct rtc_time rtc_tm; | 158 | struct rtc_time rtc_tm; |
89 | void __user *argp = (void __user *)arg; | 159 | void __user *argp = (void __user *)arg; |
90 | 160 | ||
91 | switch (cmd) | 161 | switch (cmd) { |
92 | { | 162 | /* No interrupt support, return an error |
163 | * compatible with drivers/char/rtc.c | ||
164 | */ | ||
165 | case RTC_AIE_OFF: | ||
166 | case RTC_AIE_ON: | ||
167 | case RTC_PIE_OFF: | ||
168 | case RTC_PIE_ON: | ||
169 | case RTC_UIE_OFF: | ||
170 | case RTC_UIE_ON: | ||
171 | case RTC_IRQP_READ: | ||
172 | case RTC_IRQP_SET: | ||
173 | case RTC_EPOCH_SET: | ||
174 | case RTC_EPOCH_READ: | ||
175 | return -EINVAL; | ||
176 | |||
93 | case RTCGET: | 177 | case RTCGET: |
178 | case RTC_RD_TIME: | ||
94 | memset(&rtc_tm, 0, sizeof(struct rtc_time)); | 179 | memset(&rtc_tm, 0, sizeof(struct rtc_time)); |
95 | get_rtc_time(&rtc_tm); | 180 | get_rtc_time(&rtc_tm); |
96 | 181 | ||
97 | if (copy_to_user(argp, &rtc_tm, sizeof(struct rtc_time))) | 182 | if (cmd == RTCGET) { |
183 | if (copy_to_user(argp, &rtc_tm, | ||
184 | sizeof(struct rtc_time))) | ||
185 | return -EFAULT; | ||
186 | } else if (put_rtc_time_generic(argp, &rtc_tm)) | ||
98 | return -EFAULT; | 187 | return -EFAULT; |
99 | 188 | ||
100 | return 0; | 189 | return 0; |
101 | 190 | ||
102 | 191 | ||
103 | case RTCSET: | 192 | case RTCSET: |
193 | case RTC_SET_TIME: | ||
104 | if (!capable(CAP_SYS_TIME)) | 194 | if (!capable(CAP_SYS_TIME)) |
105 | return -EPERM; | 195 | return -EPERM; |
106 | 196 | ||
107 | if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time))) | 197 | if (cmd == RTCSET) { |
198 | if (copy_from_user(&rtc_tm, argp, | ||
199 | sizeof(struct rtc_time))) | ||
200 | return -EFAULT; | ||
201 | } else if (get_rtc_time_generic(&rtc_tm, argp)) | ||
108 | return -EFAULT; | 202 | return -EFAULT; |
109 | 203 | ||
110 | set_rtc_time(&rtc_tm); | 204 | set_rtc_time(&rtc_tm); |
@@ -164,6 +258,7 @@ static int __init rtc_sun_init(void) | |||
164 | printk(KERN_ERR "rtc: unable to get misc minor for Mostek\n"); | 258 | printk(KERN_ERR "rtc: unable to get misc minor for Mostek\n"); |
165 | return error; | 259 | return error; |
166 | } | 260 | } |
261 | printk("rtc_sun_init: Registered Mostek RTC driver.\n"); | ||
167 | 262 | ||
168 | return 0; | 263 | return 0; |
169 | } | 264 | } |
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index 8caaf2e5e47c..39b788d95e39 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -682,7 +682,8 @@ static void calc_ebrg(int baud, int *n_ret, int *m_ret) | |||
682 | 682 | ||
683 | /* Internal routine, port->lock is held and local interrupts are disabled. */ | 683 | /* Internal routine, port->lock is held and local interrupts are disabled. */ |
684 | static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag, | 684 | static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag, |
685 | unsigned int iflag, int baud) | 685 | unsigned int iflag, unsigned int baud, |
686 | unsigned int quot) | ||
686 | { | 687 | { |
687 | unsigned int ebrg; | 688 | unsigned int ebrg; |
688 | unsigned char dafo; | 689 | unsigned char dafo; |
@@ -766,6 +767,9 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla | |||
766 | up->port.ignore_status_mask |= (SAB82532_ISR0_RPF | | 767 | up->port.ignore_status_mask |= (SAB82532_ISR0_RPF | |
767 | SAB82532_ISR0_TCD); | 768 | SAB82532_ISR0_TCD); |
768 | 769 | ||
770 | uart_update_timeout(&up->port, cflag, | ||
771 | (up->port.uartclk / (16 * quot))); | ||
772 | |||
769 | /* Now bang the new settings into the chip. */ | 773 | /* Now bang the new settings into the chip. */ |
770 | sunsab_cec_wait(up); | 774 | sunsab_cec_wait(up); |
771 | sunsab_tec_wait(up); | 775 | sunsab_tec_wait(up); |
@@ -784,10 +788,11 @@ static void sunsab_set_termios(struct uart_port *port, struct termios *termios, | |||
784 | { | 788 | { |
785 | struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; | 789 | struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; |
786 | unsigned long flags; | 790 | unsigned long flags; |
787 | int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); | 791 | unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); |
792 | unsigned int quot = uart_get_divisor(port, baud); | ||
788 | 793 | ||
789 | spin_lock_irqsave(&up->port.lock, flags); | 794 | spin_lock_irqsave(&up->port.lock, flags); |
790 | sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud); | 795 | sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud, quot); |
791 | spin_unlock_irqrestore(&up->port.lock, flags); | 796 | spin_unlock_irqrestore(&up->port.lock, flags); |
792 | } | 797 | } |
793 | 798 | ||
@@ -880,7 +885,7 @@ static int sunsab_console_setup(struct console *con, char *options) | |||
880 | { | 885 | { |
881 | struct uart_sunsab_port *up = &sunsab_ports[con->index]; | 886 | struct uart_sunsab_port *up = &sunsab_ports[con->index]; |
882 | unsigned long flags; | 887 | unsigned long flags; |
883 | int baud; | 888 | unsigned int baud, quot; |
884 | 889 | ||
885 | printk("Console: ttyS%d (SAB82532)\n", | 890 | printk("Console: ttyS%d (SAB82532)\n", |
886 | (sunsab_reg.minor - 64) + con->index); | 891 | (sunsab_reg.minor - 64) + con->index); |
@@ -926,7 +931,8 @@ static int sunsab_console_setup(struct console *con, char *options) | |||
926 | SAB82532_IMR1_XPR; | 931 | SAB82532_IMR1_XPR; |
927 | writeb(up->interrupt_mask1, &up->regs->w.imr1); | 932 | writeb(up->interrupt_mask1, &up->regs->w.imr1); |
928 | 933 | ||
929 | sunsab_convert_to_sab(up, con->cflag, 0, baud); | 934 | quot = uart_get_divisor(&up->port, baud); |
935 | sunsab_convert_to_sab(up, con->cflag, 0, baud, quot); | ||
930 | sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); | 936 | sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); |
931 | 937 | ||
932 | spin_unlock_irqrestore(&up->port.lock, flags); | 938 | spin_unlock_irqrestore(&up->port.lock, flags); |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index 23d19d394320..ddc97c905e14 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -1285,6 +1285,7 @@ static struct uart_driver sunsu_reg = { | |||
1285 | 1285 | ||
1286 | static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel) | 1286 | static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel) |
1287 | { | 1287 | { |
1288 | int quot, baud; | ||
1288 | #ifdef CONFIG_SERIO | 1289 | #ifdef CONFIG_SERIO |
1289 | struct serio *serio; | 1290 | struct serio *serio; |
1290 | #endif | 1291 | #endif |
@@ -1293,10 +1294,14 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel) | |||
1293 | up->port.type = PORT_UNKNOWN; | 1294 | up->port.type = PORT_UNKNOWN; |
1294 | up->port.uartclk = (SU_BASE_BAUD * 16); | 1295 | up->port.uartclk = (SU_BASE_BAUD * 16); |
1295 | 1296 | ||
1296 | if (up->su_type == SU_PORT_KBD) | 1297 | if (up->su_type == SU_PORT_KBD) { |
1297 | up->cflag = B1200 | CS8 | CLOCAL | CREAD; | 1298 | up->cflag = B1200 | CS8 | CLOCAL | CREAD; |
1298 | else | 1299 | baud = 1200; |
1300 | } else { | ||
1299 | up->cflag = B4800 | CS8 | CLOCAL | CREAD; | 1301 | up->cflag = B4800 | CS8 | CLOCAL | CREAD; |
1302 | baud = 4800; | ||
1303 | } | ||
1304 | quot = up->port.uartclk / (16 * baud); | ||
1300 | 1305 | ||
1301 | sunsu_autoconfig(up); | 1306 | sunsu_autoconfig(up); |
1302 | if (up->port.type == PORT_UNKNOWN) | 1307 | if (up->port.type == PORT_UNKNOWN) |
@@ -1337,6 +1342,8 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel) | |||
1337 | } | 1342 | } |
1338 | #endif | 1343 | #endif |
1339 | 1344 | ||
1345 | sunsu_change_speed(&up->port, up->cflag, 0, quot); | ||
1346 | |||
1340 | sunsu_startup(&up->port); | 1347 | sunsu_startup(&up->port); |
1341 | return 0; | 1348 | return 0; |
1342 | } | 1349 | } |