1 /*
2  * Copyright (C) 2001,2002,2003 Broadcom Corporation
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18 
19 #include <linux/config.h>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/errno.h>
24 
25 #include <asm/sibyte/sb1250_regs.h>
26 #include <asm/sibyte/sb1250_smbus.h>
27 
28 #include <linux/i2c.h>
29 #include <linux/i2c-algo-sibyte.h>
30 
sibyte_reg(struct i2c_client * client)31 static int sibyte_reg(struct i2c_client *client)
32 {
33 	return 0;
34 }
35 
sibyte_unreg(struct i2c_client * client)36 static int sibyte_unreg(struct i2c_client *client)
37 {
38 	return 0;
39 }
40 
sibyte_inc_use(struct i2c_adapter * adap)41 static void sibyte_inc_use(struct i2c_adapter *adap)
42 {
43 #ifdef MODULE
44 	MOD_INC_USE_COUNT;
45 #endif
46 }
47 
sibyte_dec_use(struct i2c_adapter * adap)48 static void sibyte_dec_use(struct i2c_adapter *adap)
49 {
50 #ifdef MODULE
51 	MOD_DEC_USE_COUNT;
52 #endif
53 }
54 
55 static struct i2c_algo_sibyte_data sibyte_board_data[2] = {
56         { NULL, 0, (void *)(KSEG1+A_SMB_BASE(0)) },
57         { NULL, 1, (void *)(KSEG1+A_SMB_BASE(1)) }
58 };
59 
60 static struct i2c_adapter sibyte_board_adapter[2] = {
61         {
62                 name:              "SiByte SMBus 0",
63                 id:                I2C_HW_SIBYTE,
64                 algo:              NULL,
65                 algo_data:         &sibyte_board_data[0],
66                 inc_use:           sibyte_inc_use,
67                 dec_use:           sibyte_dec_use,
68                 client_register:   sibyte_reg,
69                 client_unregister: sibyte_unreg,
70 		client_count:      0
71         } ,
72         {
73                 name:              "SiByte SMBus 1",
74                 id:                I2C_HW_SIBYTE,
75                 algo:              NULL,
76                 algo_data:         &sibyte_board_data[1],
77                 inc_use:           sibyte_inc_use,
78                 dec_use:           sibyte_dec_use,
79                 client_register:   sibyte_reg,
80                 client_unregister: sibyte_unreg,
81 		client_count:      0
82         }
83 };
84 
i2c_sibyte_init(void)85 int __init i2c_sibyte_init(void)
86 {
87 	printk("i2c-swarm.o: i2c SMBus adapter module for SiByte board\n");
88         if (i2c_sibyte_add_bus(&sibyte_board_adapter[0], K_SMB_FREQ_100KHZ) < 0)
89                 return -ENODEV;
90         if (i2c_sibyte_add_bus(&sibyte_board_adapter[1], K_SMB_FREQ_400KHZ) < 0)
91                 return -ENODEV;
92 	return 0;
93 }
94 
95 
96 EXPORT_NO_SYMBOLS;
97 
98 #ifdef MODULE
99 MODULE_AUTHOR("Kip Walker, Broadcom Corp.");
100 MODULE_DESCRIPTION("SMBus adapter routines for SiByte boards");
101 MODULE_LICENSE("GPL");
102 
init_module(void)103 int init_module(void)
104 {
105 	return i2c_sibyte_init();
106 }
107 
cleanup_module(void)108 void cleanup_module(void)
109 {
110 	i2c_sibyte_del_bus(&sibyte_board_adapter[0]);
111 	i2c_sibyte_del_bus(&sibyte_board_adapter[1]);
112 }
113 
114 #endif
115