This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / serial / mpsc / mpsc_ppc32.c
1 /*
2  * drivers/serial/mpsc/mpsc_ppc32.c
3  *
4  * Middle layer that sucks data from the ppc32 OCP--that is, chip &
5  * platform-specific data--and puts it into the mpsc_port_info_t structure
6  * for the mpsc driver to use.
7  *
8  * Author: Mark A. Greer <mgreer@mvista.com>
9  *
10  * 2004 (c) MontaVista, Software, Inc.  This file is licensed under
11  * the terms of the GNU General Public License version 2.  This program
12  * is licensed "as is" without any warranty of any kind, whether express
13  * or implied.
14  */
15 #include "mpsc.h"
16 #include <asm/ocp.h>
17 #include <asm/mv64x60.h>
18
19 static void mpsc_ocp_remove(struct ocp_device *ocpdev);
20
21 static int
22 mpsc_ocp_probe(struct ocp_device *ocpdev)
23 {
24         mpsc_port_info_t        *pi;
25         mv64x60_ocp_mpsc_data_t *dp;
26         u32                     base;
27         int                     rc = -ENODEV;
28
29         if ((pi = mpsc_device_probe(ocpdev->def->index)) != NULL) {
30                 dp = (mv64x60_ocp_mpsc_data_t *)ocpdev->def->additions;
31
32                 pi->mpsc_base_p = ocpdev->def->paddr;
33
34                 if (ocpdev->def->index == 0) {
35                         base = pi->mpsc_base_p - MV64x60_MPSC_0_OFFSET;
36                         pi->sdma_base_p = base + MV64x60_SDMA_0_OFFSET;
37                         pi->brg_base_p = base + MV64x60_BRG_0_OFFSET;
38                 }
39                 else { /* Must be 1 */
40                         base = pi->mpsc_base_p - MV64x60_MPSC_1_OFFSET;
41                         pi->sdma_base_p = base + MV64x60_SDMA_1_OFFSET;
42                         pi->brg_base_p = base + MV64x60_BRG_1_OFFSET;
43                 }
44
45                 pi->mpsc_routing_base_p = base + MV64x60_MPSC_ROUTING_OFFSET;
46                 pi->sdma_intr_base_p = base + MV64x60_SDMA_INTR_OFFSET;
47
48                 pi->port.irq = dp->sdma_irq;
49                 pi->port.uartclk = dp->brg_clk_freq;
50
51                 pi->mirror_regs = dp->mirror_regs;
52                 pi->cache_mgmt = dp->cache_mgmt;
53                 pi->brg_can_tune = dp->brg_can_tune;
54                 pi->brg_clk_src = dp->brg_clk_src;
55                 pi->mpsc_max_idle = dp->max_idle;
56                 pi->default_baud = dp->default_baud;
57                 pi->default_bits = dp->default_bits;
58                 pi->default_parity = dp->default_parity;
59                 pi->default_flow = dp->default_flow;
60
61                 /* Initial values of mirrored regs */
62                 pi->MPSC_CHR_1_m = dp->chr_1_val;
63                 pi->MPSC_CHR_2_m = dp->chr_2_val;
64                 pi->MPSC_CHR_10_m = dp->chr_10_val;
65                 pi->MPSC_MPCR_m = dp->mpcr_val;
66                 pi->MPSC_MRR_m = dp->mrr_val;
67                 pi->MPSC_RCRR_m = dp->rcrr_val;
68                 pi->MPSC_TCRR_m = dp->tcrr_val;
69                 pi->SDMA_INTR_MASK_m = dp->intr_mask_val;
70                 pi->BRG_BCR_m = dp->bcr_val;
71
72                 pi->port.iotype = UPIO_MEM;
73
74                 rc = 0;
75         }
76
77         return rc;
78 }
79
80 static void
81 mpsc_ocp_remove(struct ocp_device *ocpdev)
82 {
83         (void)mpsc_device_remove(ocpdev->def->index);
84         return;
85 }
86
87 static struct ocp_device_id mpsc_ocp_ids[] = {
88         {.vendor = OCP_VENDOR_MARVELL, .function = OCP_FUNC_MPSC},
89         {.vendor = OCP_VENDOR_INVALID}
90 };
91
92 static struct ocp_driver mpsc_ocp_driver = {
93         .name = "mpsc",
94         .id_table = mpsc_ocp_ids,
95         .probe = mpsc_ocp_probe,
96         .remove = mpsc_ocp_remove,
97 };
98
99 int
100 mpsc_platform_register_driver(void)
101 {
102         return ocp_register_driver(&mpsc_ocp_driver);
103 }
104
105 void
106 mpsc_platform_unregister_driver(void)
107 {
108         ocp_unregister_driver(&mpsc_ocp_driver);
109         return;
110 }