@@ -224,11 +224,6 @@ static void slave_rx_tasklet_fn(unsigned long);
224
224
| BIT(IS_S_TX_UNDERRUN_SHIFT) | BIT(IS_S_RX_FIFO_FULL_SHIFT)\
225
225
| BIT(IS_S_RX_THLD_SHIFT))
226
226
227
- static int bcm_iproc_i2c_reg_slave (struct i2c_client * slave );
228
- static int bcm_iproc_i2c_unreg_slave (struct i2c_client * slave );
229
- static void bcm_iproc_i2c_enable_disable (struct bcm_iproc_i2c_dev * iproc_i2c ,
230
- bool enable );
231
-
232
227
static inline u32 iproc_i2c_rd_reg (struct bcm_iproc_i2c_dev * iproc_i2c ,
233
228
u32 offset )
234
229
{
@@ -316,6 +311,19 @@ static void bcm_iproc_i2c_slave_init(struct bcm_iproc_i2c_dev *iproc_i2c,
316
311
iproc_i2c_wr_reg (iproc_i2c , IE_OFFSET , val );
317
312
}
318
313
314
+ static void bcm_iproc_i2c_enable_disable (struct bcm_iproc_i2c_dev * iproc_i2c ,
315
+ bool enable )
316
+ {
317
+ u32 val ;
318
+
319
+ val = iproc_i2c_rd_reg (iproc_i2c , CFG_OFFSET );
320
+ if (enable )
321
+ val |= BIT (CFG_EN_SHIFT );
322
+ else
323
+ val &= ~BIT (CFG_EN_SHIFT );
324
+ iproc_i2c_wr_reg (iproc_i2c , CFG_OFFSET , val );
325
+ }
326
+
319
327
static bool bcm_iproc_i2c_check_slave_status
320
328
(struct bcm_iproc_i2c_dev * iproc_i2c , u32 status )
321
329
{
@@ -707,19 +715,6 @@ static void bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev *iproc_i2c)
707
715
iproc_i2c_wr_reg (iproc_i2c , IS_OFFSET , 0xffffffff );
708
716
}
709
717
710
- static void bcm_iproc_i2c_enable_disable (struct bcm_iproc_i2c_dev * iproc_i2c ,
711
- bool enable )
712
- {
713
- u32 val ;
714
-
715
- val = iproc_i2c_rd_reg (iproc_i2c , CFG_OFFSET );
716
- if (enable )
717
- val |= BIT (CFG_EN_SHIFT );
718
- else
719
- val &= ~BIT (CFG_EN_SHIFT );
720
- iproc_i2c_wr_reg (iproc_i2c , CFG_OFFSET , val );
721
- }
722
-
723
718
static int bcm_iproc_i2c_check_status (struct bcm_iproc_i2c_dev * iproc_i2c ,
724
719
struct i2c_msg * msg )
725
720
{
@@ -988,6 +983,63 @@ static u32 bcm_iproc_i2c_functionality(struct i2c_adapter *adap)
988
983
return val ;
989
984
}
990
985
986
+ static int bcm_iproc_i2c_reg_slave (struct i2c_client * slave )
987
+ {
988
+ struct bcm_iproc_i2c_dev * iproc_i2c = i2c_get_adapdata (slave -> adapter );
989
+
990
+ if (iproc_i2c -> slave )
991
+ return - EBUSY ;
992
+
993
+ if (slave -> flags & I2C_CLIENT_TEN )
994
+ return - EAFNOSUPPORT ;
995
+
996
+ iproc_i2c -> slave = slave ;
997
+
998
+ tasklet_init (& iproc_i2c -> slave_rx_tasklet , slave_rx_tasklet_fn ,
999
+ (unsigned long )iproc_i2c );
1000
+
1001
+ bcm_iproc_i2c_slave_init (iproc_i2c , false);
1002
+
1003
+ return 0 ;
1004
+ }
1005
+
1006
+ static int bcm_iproc_i2c_unreg_slave (struct i2c_client * slave )
1007
+ {
1008
+ struct bcm_iproc_i2c_dev * iproc_i2c = i2c_get_adapdata (slave -> adapter );
1009
+ u32 tmp ;
1010
+
1011
+ if (!iproc_i2c -> slave )
1012
+ return - EINVAL ;
1013
+
1014
+ disable_irq (iproc_i2c -> irq );
1015
+
1016
+ tasklet_kill (& iproc_i2c -> slave_rx_tasklet );
1017
+
1018
+ /* disable all slave interrupts */
1019
+ tmp = iproc_i2c_rd_reg (iproc_i2c , IE_OFFSET );
1020
+ tmp &= ~(IE_S_ALL_INTERRUPT_MASK <<
1021
+ IE_S_ALL_INTERRUPT_SHIFT );
1022
+ iproc_i2c_wr_reg (iproc_i2c , IE_OFFSET , tmp );
1023
+
1024
+ /* Erase the slave address programmed */
1025
+ tmp = iproc_i2c_rd_reg (iproc_i2c , S_CFG_SMBUS_ADDR_OFFSET );
1026
+ tmp &= ~BIT (S_CFG_EN_NIC_SMB_ADDR3_SHIFT );
1027
+ iproc_i2c_wr_reg (iproc_i2c , S_CFG_SMBUS_ADDR_OFFSET , tmp );
1028
+
1029
+ /* flush TX/RX FIFOs */
1030
+ tmp = (BIT (S_FIFO_RX_FLUSH_SHIFT ) | BIT (S_FIFO_TX_FLUSH_SHIFT ));
1031
+ iproc_i2c_wr_reg (iproc_i2c , S_FIFO_CTRL_OFFSET , tmp );
1032
+
1033
+ /* clear all pending slave interrupts */
1034
+ iproc_i2c_wr_reg (iproc_i2c , IS_OFFSET , ISR_MASK_SLAVE );
1035
+
1036
+ iproc_i2c -> slave = NULL ;
1037
+
1038
+ enable_irq (iproc_i2c -> irq );
1039
+
1040
+ return 0 ;
1041
+ }
1042
+
991
1043
static struct i2c_algorithm bcm_iproc_algo = {
992
1044
.master_xfer = bcm_iproc_i2c_xfer ,
993
1045
.functionality = bcm_iproc_i2c_functionality ,
@@ -1173,62 +1225,6 @@ static const struct dev_pm_ops bcm_iproc_i2c_pm_ops = {
1173
1225
.resume_early = & bcm_iproc_i2c_resume
1174
1226
};
1175
1227
1176
- static int bcm_iproc_i2c_reg_slave (struct i2c_client * slave )
1177
- {
1178
- struct bcm_iproc_i2c_dev * iproc_i2c = i2c_get_adapdata (slave -> adapter );
1179
-
1180
- if (iproc_i2c -> slave )
1181
- return - EBUSY ;
1182
-
1183
- if (slave -> flags & I2C_CLIENT_TEN )
1184
- return - EAFNOSUPPORT ;
1185
-
1186
- iproc_i2c -> slave = slave ;
1187
-
1188
- tasklet_init (& iproc_i2c -> slave_rx_tasklet , slave_rx_tasklet_fn ,
1189
- (unsigned long )iproc_i2c );
1190
-
1191
- bcm_iproc_i2c_slave_init (iproc_i2c , false);
1192
- return 0 ;
1193
- }
1194
-
1195
- static int bcm_iproc_i2c_unreg_slave (struct i2c_client * slave )
1196
- {
1197
- u32 tmp ;
1198
- struct bcm_iproc_i2c_dev * iproc_i2c = i2c_get_adapdata (slave -> adapter );
1199
-
1200
- if (!iproc_i2c -> slave )
1201
- return - EINVAL ;
1202
-
1203
- disable_irq (iproc_i2c -> irq );
1204
-
1205
- tasklet_kill (& iproc_i2c -> slave_rx_tasklet );
1206
-
1207
- /* disable all slave interrupts */
1208
- tmp = iproc_i2c_rd_reg (iproc_i2c , IE_OFFSET );
1209
- tmp &= ~(IE_S_ALL_INTERRUPT_MASK <<
1210
- IE_S_ALL_INTERRUPT_SHIFT );
1211
- iproc_i2c_wr_reg (iproc_i2c , IE_OFFSET , tmp );
1212
-
1213
- /* Erase the slave address programmed */
1214
- tmp = iproc_i2c_rd_reg (iproc_i2c , S_CFG_SMBUS_ADDR_OFFSET );
1215
- tmp &= ~BIT (S_CFG_EN_NIC_SMB_ADDR3_SHIFT );
1216
- iproc_i2c_wr_reg (iproc_i2c , S_CFG_SMBUS_ADDR_OFFSET , tmp );
1217
-
1218
- /* flush TX/RX FIFOs */
1219
- tmp = (BIT (S_FIFO_RX_FLUSH_SHIFT ) | BIT (S_FIFO_TX_FLUSH_SHIFT ));
1220
- iproc_i2c_wr_reg (iproc_i2c , S_FIFO_CTRL_OFFSET , tmp );
1221
-
1222
- /* clear all pending slave interrupts */
1223
- iproc_i2c_wr_reg (iproc_i2c , IS_OFFSET , ISR_MASK_SLAVE );
1224
-
1225
- iproc_i2c -> slave = NULL ;
1226
-
1227
- enable_irq (iproc_i2c -> irq );
1228
-
1229
- return 0 ;
1230
- }
1231
-
1232
1228
static const struct of_device_id bcm_iproc_i2c_of_match [] = {
1233
1229
{
1234
1230
.compatible = "brcm,iproc-i2c" ,
0 commit comments