@@ -35,7 +35,7 @@ static int viai2c_write(struct viai2c *i2c, struct i2c_msg *pmsg, int last)
3535 writew (pmsg -> buf [0 ] & 0xFF , i2c -> base + VIAI2C_REG_CDR );
3636 }
3737
38- if (!(pmsg -> flags & I2C_M_NOSTART )) {
38+ if (i2c -> platform == VIAI2C_PLAT_WMT && !(pmsg -> flags & I2C_M_NOSTART )) {
3939 val = readw (i2c -> base + VIAI2C_REG_CR );
4040 val &= ~VIAI2C_CR_TX_END ;
4141 val |= VIAI2C_CR_CPU_RDY ;
@@ -48,7 +48,7 @@ static int viai2c_write(struct viai2c *i2c, struct i2c_msg *pmsg, int last)
4848
4949 writew (tcr_val , i2c -> base + VIAI2C_REG_TCR );
5050
51- if (pmsg -> flags & I2C_M_NOSTART ) {
51+ if (i2c -> platform == VIAI2C_PLAT_WMT && pmsg -> flags & I2C_M_NOSTART ) {
5252 val = readw (i2c -> base + VIAI2C_REG_CR );
5353 val |= VIAI2C_CR_CPU_RDY ;
5454 writew (val , i2c -> base + VIAI2C_REG_CR );
@@ -67,7 +67,7 @@ static int viai2c_read(struct viai2c *i2c, struct i2c_msg *pmsg)
6767 val = readw (i2c -> base + VIAI2C_REG_CR );
6868 val &= ~(VIAI2C_CR_TX_END | VIAI2C_CR_RX_END );
6969
70- if (!(pmsg -> flags & I2C_M_NOSTART ))
70+ if (i2c -> platform == VIAI2C_PLAT_WMT && !(pmsg -> flags & I2C_M_NOSTART ))
7171 val |= VIAI2C_CR_CPU_RDY ;
7272
7373 if (pmsg -> len == 1 )
@@ -81,7 +81,7 @@ static int viai2c_read(struct viai2c *i2c, struct i2c_msg *pmsg)
8181
8282 writew (tcr_val , i2c -> base + VIAI2C_REG_TCR );
8383
84- if (pmsg -> flags & I2C_M_NOSTART ) {
84+ if (i2c -> platform == VIAI2C_PLAT_WMT && ( pmsg -> flags & I2C_M_NOSTART ) ) {
8585 val = readw (i2c -> base + VIAI2C_REG_CR );
8686 val |= VIAI2C_CR_CPU_RDY ;
8787 writew (val , i2c -> base + VIAI2C_REG_CR );
@@ -102,7 +102,7 @@ int viai2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
102102
103103 for (i = 0 ; ret >= 0 && i < num ; i ++ ) {
104104 pmsg = & msgs [i ];
105- if (!(pmsg -> flags & I2C_M_NOSTART )) {
105+ if (i2c -> platform == VIAI2C_PLAT_WMT && !(pmsg -> flags & I2C_M_NOSTART )) {
106106 ret = viai2c_wait_bus_not_busy (i2c );
107107 if (ret < 0 )
108108 return ret ;
@@ -155,7 +155,7 @@ static int viai2c_irq_xfer(struct viai2c *i2c)
155155 }
156156
157157 if ((i2c -> xfered_len + 1 ) == msg -> len ) {
158- if (!i2c -> last )
158+ if (i2c -> platform == VIAI2C_PLAT_WMT && !i2c -> last )
159159 writew (VIAI2C_CR_ENABLE , base + VIAI2C_REG_CR );
160160 } else {
161161 writew (msg -> buf [i2c -> xfered_len + 1 ] & 0xFF , base + VIAI2C_REG_CDR );
@@ -181,7 +181,7 @@ static irqreturn_t viai2c_isr(int irq, void *data)
181181 if (status & VIAI2C_ISR_NACK_ADDR )
182182 i2c -> ret = - EIO ;
183183
184- if (status & VIAI2C_ISR_SCL_TIMEOUT )
184+ if (i2c -> platform == VIAI2C_PLAT_WMT && ( status & VIAI2C_ISR_SCL_TIMEOUT ) )
185185 i2c -> ret = - ETIMEDOUT ;
186186
187187 if (!i2c -> ret )
@@ -194,9 +194,10 @@ static irqreturn_t viai2c_isr(int irq, void *data)
194194 return IRQ_HANDLED ;
195195}
196196
197- int viai2c_init (struct platform_device * pdev , struct viai2c * * pi2c )
197+ int viai2c_init (struct platform_device * pdev , struct viai2c * * pi2c , int plat )
198198{
199199 int err ;
200+ int irq_flags ;
200201 struct viai2c * i2c ;
201202 struct device_node * np = pdev -> dev .of_node ;
202203
@@ -208,12 +209,19 @@ int viai2c_init(struct platform_device *pdev, struct viai2c **pi2c)
208209 if (IS_ERR (i2c -> base ))
209210 return PTR_ERR (i2c -> base );
210211
211- i2c -> irq = irq_of_parse_and_map (np , 0 );
212- if (!i2c -> irq )
213- return - EINVAL ;
212+ if (plat == VIAI2C_PLAT_WMT ) {
213+ irq_flags = 0 ;
214+ i2c -> irq = irq_of_parse_and_map (np , 0 );
215+ if (!i2c -> irq )
216+ return - EINVAL ;
217+ } else {
218+ return dev_err_probe (& pdev -> dev , - EINVAL , "wrong platform type\n" );
219+ }
220+
221+ i2c -> platform = plat ;
214222
215223 err = devm_request_irq (& pdev -> dev , i2c -> irq , viai2c_isr ,
216- 0 , pdev -> name , i2c );
224+ irq_flags , pdev -> name , i2c );
217225 if (err )
218226 return dev_err_probe (& pdev -> dev , err ,
219227 "failed to request irq %i\n" , i2c -> irq );
0 commit comments