aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHayes Wang <hayeswang@realtek.com>2012-03-30 02:33:01 -0400
committerFrancois Romieu <romieu@fr.zoreil.com>2012-04-17 05:22:40 -0400
commitbeb1fe184f673fae83ddd9beca3fe662019ef876 (patch)
tree1b84402106b8ace988d3fa3f732955b361fdec67
parent0004299ad41885a0a1fd321715fe7396be17ce35 (diff)
r8169: add device specific CSI access helpers.
New chipsets need it. Signed-off-by: Hayes Wang <hayeswang@realtek.com>
-rw-r--r--drivers/net/ethernet/realtek/r8169.c300
1 files changed, 194 insertions, 106 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index d9bae307c144..8a9cb209cb58 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -718,6 +718,11 @@ struct rtl8169_private {
718 void (*disable)(struct rtl8169_private *); 718 void (*disable)(struct rtl8169_private *);
719 } jumbo_ops; 719 } jumbo_ops;
720 720
721 struct csi_ops {
722 void (*write)(void __iomem *, int, int);
723 u32 (*read)(void __iomem *, int);
724 } csi_ops;
725
721 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv); 726 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
722 int (*get_settings)(struct net_device *, struct ethtool_cmd *); 727 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
723 void (*phy_reset_enable)(struct rtl8169_private *tp); 728 void (*phy_reset_enable)(struct rtl8169_private *tp);
@@ -1080,40 +1085,6 @@ static u16 rtl_ephy_read(void __iomem *ioaddr, int reg_addr)
1080 return value; 1085 return value;
1081} 1086}
1082 1087
1083static void rtl_csi_write(void __iomem *ioaddr, int addr, int value)
1084{
1085 unsigned int i;
1086
1087 RTL_W32(CSIDR, value);
1088 RTL_W32(CSIAR, CSIAR_WRITE_CMD | (addr & CSIAR_ADDR_MASK) |
1089 CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
1090
1091 for (i = 0; i < 100; i++) {
1092 if (!(RTL_R32(CSIAR) & CSIAR_FLAG))
1093 break;
1094 udelay(10);
1095 }
1096}
1097
1098static u32 rtl_csi_read(void __iomem *ioaddr, int addr)
1099{
1100 u32 value = ~0x00;
1101 unsigned int i;
1102
1103 RTL_W32(CSIAR, (addr & CSIAR_ADDR_MASK) |
1104 CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
1105
1106 for (i = 0; i < 100; i++) {
1107 if (RTL_R32(CSIAR) & CSIAR_FLAG) {
1108 value = RTL_R32(CSIDR);
1109 break;
1110 }
1111 udelay(10);
1112 }
1113
1114 return value;
1115}
1116
1117static 1088static
1118void rtl_eri_write(void __iomem *ioaddr, int addr, u32 mask, u32 val, int type) 1089void rtl_eri_write(void __iomem *ioaddr, int addr, u32 mask, u32 val, int type)
1119{ 1090{
@@ -4226,22 +4197,100 @@ static void rtl_hw_start_8169(struct net_device *dev)
4226 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000); 4197 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
4227} 4198}
4228 4199
4229static void rtl_csi_access_enable(void __iomem *ioaddr, u32 bits) 4200static void rtl_csi_write(struct rtl8169_private *tp, int addr, int value)
4201{
4202 if (tp->csi_ops.write)
4203 tp->csi_ops.write(tp->mmio_addr, addr, value);
4204}
4205
4206static u32 rtl_csi_read(struct rtl8169_private *tp, int addr)
4207{
4208 if (tp->csi_ops.read)
4209 return tp->csi_ops.read(tp->mmio_addr, addr);
4210 else
4211 return ~0;
4212}
4213
4214static void rtl_csi_access_enable(struct rtl8169_private *tp, u32 bits)
4230{ 4215{
4231 u32 csi; 4216 u32 csi;
4232 4217
4233 csi = rtl_csi_read(ioaddr, 0x070c) & 0x00ffffff; 4218 csi = rtl_csi_read(tp, 0x070c) & 0x00ffffff;
4234 rtl_csi_write(ioaddr, 0x070c, csi | bits); 4219 rtl_csi_write(tp, 0x070c, csi | bits);
4220}
4221
4222static void rtl_csi_access_enable_1(struct rtl8169_private *tp)
4223{
4224 rtl_csi_access_enable(tp, 0x17000000);
4235} 4225}
4236 4226
4237static void rtl_csi_access_enable_1(void __iomem *ioaddr) 4227static void rtl_csi_access_enable_2(struct rtl8169_private *tp)
4238{ 4228{
4239 rtl_csi_access_enable(ioaddr, 0x17000000); 4229 rtl_csi_access_enable(tp, 0x27000000);
4240} 4230}
4241 4231
4242static void rtl_csi_access_enable_2(void __iomem *ioaddr) 4232static void r8169_csi_write(void __iomem *ioaddr, int addr, int value)
4243{ 4233{
4244 rtl_csi_access_enable(ioaddr, 0x27000000); 4234 unsigned int i;
4235
4236 RTL_W32(CSIDR, value);
4237 RTL_W32(CSIAR, CSIAR_WRITE_CMD | (addr & CSIAR_ADDR_MASK) |
4238 CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
4239
4240 for (i = 0; i < 100; i++) {
4241 if (!(RTL_R32(CSIAR) & CSIAR_FLAG))
4242 break;
4243 udelay(10);
4244 }
4245}
4246
4247static u32 r8169_csi_read(void __iomem *ioaddr, int addr)
4248{
4249 u32 value = ~0x00;
4250 unsigned int i;
4251
4252 RTL_W32(CSIAR, (addr & CSIAR_ADDR_MASK) |
4253 CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
4254
4255 for (i = 0; i < 100; i++) {
4256 if (RTL_R32(CSIAR) & CSIAR_FLAG) {
4257 value = RTL_R32(CSIDR);
4258 break;
4259 }
4260 udelay(10);
4261 }
4262
4263 return value;
4264}
4265
4266static void __devinit rtl_init_csi_ops(struct rtl8169_private *tp)
4267{
4268 struct csi_ops *ops = &tp->csi_ops;
4269
4270 switch (tp->mac_version) {
4271 case RTL_GIGA_MAC_VER_01:
4272 case RTL_GIGA_MAC_VER_02:
4273 case RTL_GIGA_MAC_VER_03:
4274 case RTL_GIGA_MAC_VER_04:
4275 case RTL_GIGA_MAC_VER_05:
4276 case RTL_GIGA_MAC_VER_06:
4277 case RTL_GIGA_MAC_VER_10:
4278 case RTL_GIGA_MAC_VER_11:
4279 case RTL_GIGA_MAC_VER_12:
4280 case RTL_GIGA_MAC_VER_13:
4281 case RTL_GIGA_MAC_VER_14:
4282 case RTL_GIGA_MAC_VER_15:
4283 case RTL_GIGA_MAC_VER_16:
4284 case RTL_GIGA_MAC_VER_17:
4285 ops->write = NULL;
4286 ops->read = NULL;
4287 break;
4288
4289 default:
4290 ops->write = r8169_csi_write;
4291 ops->read = r8169_csi_read;
4292 break;
4293 }
4245} 4294}
4246 4295
4247struct ephy_info { 4296struct ephy_info {
@@ -4298,8 +4347,11 @@ static void rtl_enable_clock_request(struct pci_dev *pdev)
4298 PktCntrDisable | \ 4347 PktCntrDisable | \
4299 Mac_dbgo_sel) 4348 Mac_dbgo_sel)
4300 4349
4301static void rtl_hw_start_8168bb(void __iomem *ioaddr, struct pci_dev *pdev) 4350static void rtl_hw_start_8168bb(struct rtl8169_private *tp)
4302{ 4351{
4352 void __iomem *ioaddr = tp->mmio_addr;
4353 struct pci_dev *pdev = tp->pci_dev;
4354
4303 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); 4355 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
4304 4356
4305 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4357 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
@@ -4308,17 +4360,22 @@ static void rtl_hw_start_8168bb(void __iomem *ioaddr, struct pci_dev *pdev)
4308 (0x5 << MAX_READ_REQUEST_SHIFT) | PCI_EXP_DEVCTL_NOSNOOP_EN); 4360 (0x5 << MAX_READ_REQUEST_SHIFT) | PCI_EXP_DEVCTL_NOSNOOP_EN);
4309} 4361}
4310 4362
4311static void rtl_hw_start_8168bef(void __iomem *ioaddr, struct pci_dev *pdev) 4363static void rtl_hw_start_8168bef(struct rtl8169_private *tp)
4312{ 4364{
4313 rtl_hw_start_8168bb(ioaddr, pdev); 4365 void __iomem *ioaddr = tp->mmio_addr;
4366
4367 rtl_hw_start_8168bb(tp);
4314 4368
4315 RTL_W8(MaxTxPacketSize, TxPacketMax); 4369 RTL_W8(MaxTxPacketSize, TxPacketMax);
4316 4370
4317 RTL_W8(Config4, RTL_R8(Config4) & ~(1 << 0)); 4371 RTL_W8(Config4, RTL_R8(Config4) & ~(1 << 0));
4318} 4372}
4319 4373
4320static void __rtl_hw_start_8168cp(void __iomem *ioaddr, struct pci_dev *pdev) 4374static void __rtl_hw_start_8168cp(struct rtl8169_private *tp)
4321{ 4375{
4376 void __iomem *ioaddr = tp->mmio_addr;
4377 struct pci_dev *pdev = tp->pci_dev;
4378
4322 RTL_W8(Config1, RTL_R8(Config1) | Speed_down); 4379 RTL_W8(Config1, RTL_R8(Config1) | Speed_down);
4323 4380
4324 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); 4381 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
@@ -4330,8 +4387,9 @@ static void __rtl_hw_start_8168cp(void __iomem *ioaddr, struct pci_dev *pdev)
4330 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4387 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
4331} 4388}
4332 4389
4333static void rtl_hw_start_8168cp_1(void __iomem *ioaddr, struct pci_dev *pdev) 4390static void rtl_hw_start_8168cp_1(struct rtl8169_private *tp)
4334{ 4391{
4392 void __iomem *ioaddr = tp->mmio_addr;
4335 static const struct ephy_info e_info_8168cp[] = { 4393 static const struct ephy_info e_info_8168cp[] = {
4336 { 0x01, 0, 0x0001 }, 4394 { 0x01, 0, 0x0001 },
4337 { 0x02, 0x0800, 0x1000 }, 4395 { 0x02, 0x0800, 0x1000 },
@@ -4340,16 +4398,19 @@ static void rtl_hw_start_8168cp_1(void __iomem *ioaddr, struct pci_dev *pdev)
4340 { 0x07, 0, 0x2000 } 4398 { 0x07, 0, 0x2000 }
4341 }; 4399 };
4342 4400
4343 rtl_csi_access_enable_2(ioaddr); 4401 rtl_csi_access_enable_2(tp);
4344 4402
4345 rtl_ephy_init(ioaddr, e_info_8168cp, ARRAY_SIZE(e_info_8168cp)); 4403 rtl_ephy_init(ioaddr, e_info_8168cp, ARRAY_SIZE(e_info_8168cp));
4346 4404
4347 __rtl_hw_start_8168cp(ioaddr, pdev); 4405 __rtl_hw_start_8168cp(tp);
4348} 4406}
4349 4407
4350static void rtl_hw_start_8168cp_2(void __iomem *ioaddr, struct pci_dev *pdev) 4408static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp)
4351{ 4409{
4352 rtl_csi_access_enable_2(ioaddr); 4410 void __iomem *ioaddr = tp->mmio_addr;
4411 struct pci_dev *pdev = tp->pci_dev;
4412
4413 rtl_csi_access_enable_2(tp);
4353 4414
4354 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); 4415 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
4355 4416
@@ -4358,9 +4419,12 @@ static void rtl_hw_start_8168cp_2(void __iomem *ioaddr, struct pci_dev *pdev)
4358 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4419 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
4359} 4420}
4360 4421
4361static void rtl_hw_start_8168cp_3(void __iomem *ioaddr, struct pci_dev *pdev) 4422static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
4362{ 4423{
4363 rtl_csi_access_enable_2(ioaddr); 4424 void __iomem *ioaddr = tp->mmio_addr;
4425 struct pci_dev *pdev = tp->pci_dev;
4426
4427 rtl_csi_access_enable_2(tp);
4364 4428
4365 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); 4429 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
4366 4430
@@ -4374,52 +4438,57 @@ static void rtl_hw_start_8168cp_3(void __iomem *ioaddr, struct pci_dev *pdev)
4374 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4438 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
4375} 4439}
4376 4440
4377static void rtl_hw_start_8168c_1(void __iomem *ioaddr, struct pci_dev *pdev) 4441static void rtl_hw_start_8168c_1(struct rtl8169_private *tp)
4378{ 4442{
4443 void __iomem *ioaddr = tp->mmio_addr;
4379 static const struct ephy_info e_info_8168c_1[] = { 4444 static const struct ephy_info e_info_8168c_1[] = {
4380 { 0x02, 0x0800, 0x1000 }, 4445 { 0x02, 0x0800, 0x1000 },
4381 { 0x03, 0, 0x0002 }, 4446 { 0x03, 0, 0x0002 },
4382 { 0x06, 0x0080, 0x0000 } 4447 { 0x06, 0x0080, 0x0000 }
4383 }; 4448 };
4384 4449
4385 rtl_csi_access_enable_2(ioaddr); 4450 rtl_csi_access_enable_2(tp);
4386 4451
4387 RTL_W8(DBG_REG, 0x06 | FIX_NAK_1 | FIX_NAK_2); 4452 RTL_W8(DBG_REG, 0x06 | FIX_NAK_1 | FIX_NAK_2);
4388 4453
4389 rtl_ephy_init(ioaddr, e_info_8168c_1, ARRAY_SIZE(e_info_8168c_1)); 4454 rtl_ephy_init(ioaddr, e_info_8168c_1, ARRAY_SIZE(e_info_8168c_1));
4390 4455
4391 __rtl_hw_start_8168cp(ioaddr, pdev); 4456 __rtl_hw_start_8168cp(tp);
4392} 4457}
4393 4458
4394static void rtl_hw_start_8168c_2(void __iomem *ioaddr, struct pci_dev *pdev) 4459static void rtl_hw_start_8168c_2(struct rtl8169_private *tp)
4395{ 4460{
4461 void __iomem *ioaddr = tp->mmio_addr;
4396 static const struct ephy_info e_info_8168c_2[] = { 4462 static const struct ephy_info e_info_8168c_2[] = {
4397 { 0x01, 0, 0x0001 }, 4463 { 0x01, 0, 0x0001 },
4398 { 0x03, 0x0400, 0x0220 } 4464 { 0x03, 0x0400, 0x0220 }
4399 }; 4465 };
4400 4466
4401 rtl_csi_access_enable_2(ioaddr); 4467 rtl_csi_access_enable_2(tp);
4402 4468
4403 rtl_ephy_init(ioaddr, e_info_8168c_2, ARRAY_SIZE(e_info_8168c_2)); 4469 rtl_ephy_init(ioaddr, e_info_8168c_2, ARRAY_SIZE(e_info_8168c_2));
4404 4470
4405 __rtl_hw_start_8168cp(ioaddr, pdev); 4471 __rtl_hw_start_8168cp(tp);
4406} 4472}
4407 4473
4408static void rtl_hw_start_8168c_3(void __iomem *ioaddr, struct pci_dev *pdev) 4474static void rtl_hw_start_8168c_3(struct rtl8169_private *tp)
4409{ 4475{
4410 rtl_hw_start_8168c_2(ioaddr, pdev); 4476 rtl_hw_start_8168c_2(tp);
4411} 4477}
4412 4478
4413static void rtl_hw_start_8168c_4(void __iomem *ioaddr, struct pci_dev *pdev) 4479static void rtl_hw_start_8168c_4(struct rtl8169_private *tp)
4414{ 4480{
4415 rtl_csi_access_enable_2(ioaddr); 4481 rtl_csi_access_enable_2(tp);
4416 4482
4417 __rtl_hw_start_8168cp(ioaddr, pdev); 4483 __rtl_hw_start_8168cp(tp);
4418} 4484}
4419 4485
4420static void rtl_hw_start_8168d(void __iomem *ioaddr, struct pci_dev *pdev) 4486static void rtl_hw_start_8168d(struct rtl8169_private *tp)
4421{ 4487{
4422 rtl_csi_access_enable_2(ioaddr); 4488 void __iomem *ioaddr = tp->mmio_addr;
4489 struct pci_dev *pdev = tp->pci_dev;
4490
4491 rtl_csi_access_enable_2(tp);
4423 4492
4424 rtl_disable_clock_request(pdev); 4493 rtl_disable_clock_request(pdev);
4425 4494
@@ -4430,9 +4499,12 @@ static void rtl_hw_start_8168d(void __iomem *ioaddr, struct pci_dev *pdev)
4430 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK); 4499 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) & ~R8168_CPCMD_QUIRK_MASK);
4431} 4500}
4432 4501
4433static void rtl_hw_start_8168dp(void __iomem *ioaddr, struct pci_dev *pdev) 4502static void rtl_hw_start_8168dp(struct rtl8169_private *tp)
4434{ 4503{
4435 rtl_csi_access_enable_1(ioaddr); 4504 void __iomem *ioaddr = tp->mmio_addr;
4505 struct pci_dev *pdev = tp->pci_dev;
4506
4507 rtl_csi_access_enable_1(tp);
4436 4508
4437 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4509 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
4438 4510
@@ -4441,8 +4513,10 @@ static void rtl_hw_start_8168dp(void __iomem *ioaddr, struct pci_dev *pdev)
4441 rtl_disable_clock_request(pdev); 4513 rtl_disable_clock_request(pdev);
4442} 4514}
4443 4515
4444static void rtl_hw_start_8168d_4(void __iomem *ioaddr, struct pci_dev *pdev) 4516static void rtl_hw_start_8168d_4(struct rtl8169_private *tp)
4445{ 4517{
4518 void __iomem *ioaddr = tp->mmio_addr;
4519 struct pci_dev *pdev = tp->pci_dev;
4446 static const struct ephy_info e_info_8168d_4[] = { 4520 static const struct ephy_info e_info_8168d_4[] = {
4447 { 0x0b, ~0, 0x48 }, 4521 { 0x0b, ~0, 0x48 },
4448 { 0x19, 0x20, 0x50 }, 4522 { 0x19, 0x20, 0x50 },
@@ -4450,7 +4524,7 @@ static void rtl_hw_start_8168d_4(void __iomem *ioaddr, struct pci_dev *pdev)
4450 }; 4524 };
4451 int i; 4525 int i;
4452 4526
4453 rtl_csi_access_enable_1(ioaddr); 4527 rtl_csi_access_enable_1(tp);
4454 4528
4455 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4529 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
4456 4530
@@ -4467,8 +4541,10 @@ static void rtl_hw_start_8168d_4(void __iomem *ioaddr, struct pci_dev *pdev)
4467 rtl_enable_clock_request(pdev); 4541 rtl_enable_clock_request(pdev);
4468} 4542}
4469 4543
4470static void rtl_hw_start_8168e_1(void __iomem *ioaddr, struct pci_dev *pdev) 4544static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
4471{ 4545{
4546 void __iomem *ioaddr = tp->mmio_addr;
4547 struct pci_dev *pdev = tp->pci_dev;
4472 static const struct ephy_info e_info_8168e_1[] = { 4548 static const struct ephy_info e_info_8168e_1[] = {
4473 { 0x00, 0x0200, 0x0100 }, 4549 { 0x00, 0x0200, 0x0100 },
4474 { 0x00, 0x0000, 0x0004 }, 4550 { 0x00, 0x0000, 0x0004 },
@@ -4485,7 +4561,7 @@ static void rtl_hw_start_8168e_1(void __iomem *ioaddr, struct pci_dev *pdev)
4485 { 0x0a, 0x0000, 0x0040 } 4561 { 0x0a, 0x0000, 0x0040 }
4486 }; 4562 };
4487 4563
4488 rtl_csi_access_enable_2(ioaddr); 4564 rtl_csi_access_enable_2(tp);
4489 4565
4490 rtl_ephy_init(ioaddr, e_info_8168e_1, ARRAY_SIZE(e_info_8168e_1)); 4566 rtl_ephy_init(ioaddr, e_info_8168e_1, ARRAY_SIZE(e_info_8168e_1));
4491 4567
@@ -4502,14 +4578,16 @@ static void rtl_hw_start_8168e_1(void __iomem *ioaddr, struct pci_dev *pdev)
4502 RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); 4578 RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
4503} 4579}
4504 4580
4505static void rtl_hw_start_8168e_2(void __iomem *ioaddr, struct pci_dev *pdev) 4581static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
4506{ 4582{
4583 void __iomem *ioaddr = tp->mmio_addr;
4584 struct pci_dev *pdev = tp->pci_dev;
4507 static const struct ephy_info e_info_8168e_2[] = { 4585 static const struct ephy_info e_info_8168e_2[] = {
4508 { 0x09, 0x0000, 0x0080 }, 4586 { 0x09, 0x0000, 0x0080 },
4509 { 0x19, 0x0000, 0x0224 } 4587 { 0x19, 0x0000, 0x0224 }
4510 }; 4588 };
4511 4589
4512 rtl_csi_access_enable_1(ioaddr); 4590 rtl_csi_access_enable_1(tp);
4513 4591
4514 rtl_ephy_init(ioaddr, e_info_8168e_2, ARRAY_SIZE(e_info_8168e_2)); 4592 rtl_ephy_init(ioaddr, e_info_8168e_2, ARRAY_SIZE(e_info_8168e_2));
4515 4593
@@ -4540,8 +4618,10 @@ static void rtl_hw_start_8168e_2(void __iomem *ioaddr, struct pci_dev *pdev)
4540 RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en); 4618 RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
4541} 4619}
4542 4620
4543static void rtl_hw_start_8168f_1(void __iomem *ioaddr, struct pci_dev *pdev) 4621static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
4544{ 4622{
4623 void __iomem *ioaddr = tp->mmio_addr;
4624 struct pci_dev *pdev = tp->pci_dev;
4545 static const struct ephy_info e_info_8168f_1[] = { 4625 static const struct ephy_info e_info_8168f_1[] = {
4546 { 0x06, 0x00c0, 0x0020 }, 4626 { 0x06, 0x00c0, 0x0020 },
4547 { 0x08, 0x0001, 0x0002 }, 4627 { 0x08, 0x0001, 0x0002 },
@@ -4549,7 +4629,7 @@ static void rtl_hw_start_8168f_1(void __iomem *ioaddr, struct pci_dev *pdev)
4549 { 0x19, 0x0000, 0x0224 } 4629 { 0x19, 0x0000, 0x0224 }
4550 }; 4630 };
4551 4631
4552 rtl_csi_access_enable_1(ioaddr); 4632 rtl_csi_access_enable_1(tp);
4553 4633
4554 rtl_ephy_init(ioaddr, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1)); 4634 rtl_ephy_init(ioaddr, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1));
4555 4635
@@ -4587,7 +4667,6 @@ static void rtl_hw_start_8168(struct net_device *dev)
4587{ 4667{
4588 struct rtl8169_private *tp = netdev_priv(dev); 4668 struct rtl8169_private *tp = netdev_priv(dev);
4589 void __iomem *ioaddr = tp->mmio_addr; 4669 void __iomem *ioaddr = tp->mmio_addr;
4590 struct pci_dev *pdev = tp->pci_dev;
4591 4670
4592 RTL_W8(Cfg9346, Cfg9346_Unlock); 4671 RTL_W8(Cfg9346, Cfg9346_Unlock);
4593 4672
@@ -4618,67 +4697,67 @@ static void rtl_hw_start_8168(struct net_device *dev)
4618 4697
4619 switch (tp->mac_version) { 4698 switch (tp->mac_version) {
4620 case RTL_GIGA_MAC_VER_11: 4699 case RTL_GIGA_MAC_VER_11:
4621 rtl_hw_start_8168bb(ioaddr, pdev); 4700 rtl_hw_start_8168bb(tp);
4622 break; 4701 break;
4623 4702
4624 case RTL_GIGA_MAC_VER_12: 4703 case RTL_GIGA_MAC_VER_12:
4625 case RTL_GIGA_MAC_VER_17: 4704 case RTL_GIGA_MAC_VER_17:
4626 rtl_hw_start_8168bef(ioaddr, pdev); 4705 rtl_hw_start_8168bef(tp);
4627 break; 4706 break;
4628 4707
4629 case RTL_GIGA_MAC_VER_18: 4708 case RTL_GIGA_MAC_VER_18:
4630 rtl_hw_start_8168cp_1(ioaddr, pdev); 4709 rtl_hw_start_8168cp_1(tp);
4631 break; 4710 break;
4632 4711
4633 case RTL_GIGA_MAC_VER_19: 4712 case RTL_GIGA_MAC_VER_19:
4634 rtl_hw_start_8168c_1(ioaddr, pdev); 4713 rtl_hw_start_8168c_1(tp);
4635 break; 4714 break;
4636 4715
4637 case RTL_GIGA_MAC_VER_20: 4716 case RTL_GIGA_MAC_VER_20:
4638 rtl_hw_start_8168c_2(ioaddr, pdev); 4717 rtl_hw_start_8168c_2(tp);
4639 break; 4718 break;
4640 4719
4641 case RTL_GIGA_MAC_VER_21: 4720 case RTL_GIGA_MAC_VER_21:
4642 rtl_hw_start_8168c_3(ioaddr, pdev); 4721 rtl_hw_start_8168c_3(tp);
4643 break; 4722 break;
4644 4723
4645 case RTL_GIGA_MAC_VER_22: 4724 case RTL_GIGA_MAC_VER_22:
4646 rtl_hw_start_8168c_4(ioaddr, pdev); 4725 rtl_hw_start_8168c_4(tp);
4647 break; 4726 break;
4648 4727
4649 case RTL_GIGA_MAC_VER_23: 4728 case RTL_GIGA_MAC_VER_23:
4650 rtl_hw_start_8168cp_2(ioaddr, pdev); 4729 rtl_hw_start_8168cp_2(tp);
4651 break; 4730 break;
4652 4731
4653 case RTL_GIGA_MAC_VER_24: 4732 case RTL_GIGA_MAC_VER_24:
4654 rtl_hw_start_8168cp_3(ioaddr, pdev); 4733 rtl_hw_start_8168cp_3(tp);
4655 break; 4734 break;
4656 4735
4657 case RTL_GIGA_MAC_VER_25: 4736 case RTL_GIGA_MAC_VER_25:
4658 case RTL_GIGA_MAC_VER_26: 4737 case RTL_GIGA_MAC_VER_26:
4659 case RTL_GIGA_MAC_VER_27: 4738 case RTL_GIGA_MAC_VER_27:
4660 rtl_hw_start_8168d(ioaddr, pdev); 4739 rtl_hw_start_8168d(tp);
4661 break; 4740 break;
4662 4741
4663 case RTL_GIGA_MAC_VER_28: 4742 case RTL_GIGA_MAC_VER_28:
4664 rtl_hw_start_8168d_4(ioaddr, pdev); 4743 rtl_hw_start_8168d_4(tp);
4665 break; 4744 break;
4666 4745
4667 case RTL_GIGA_MAC_VER_31: 4746 case RTL_GIGA_MAC_VER_31:
4668 rtl_hw_start_8168dp(ioaddr, pdev); 4747 rtl_hw_start_8168dp(tp);
4669 break; 4748 break;
4670 4749
4671 case RTL_GIGA_MAC_VER_32: 4750 case RTL_GIGA_MAC_VER_32:
4672 case RTL_GIGA_MAC_VER_33: 4751 case RTL_GIGA_MAC_VER_33:
4673 rtl_hw_start_8168e_1(ioaddr, pdev); 4752 rtl_hw_start_8168e_1(tp);
4674 break; 4753 break;
4675 case RTL_GIGA_MAC_VER_34: 4754 case RTL_GIGA_MAC_VER_34:
4676 rtl_hw_start_8168e_2(ioaddr, pdev); 4755 rtl_hw_start_8168e_2(tp);
4677 break; 4756 break;
4678 4757
4679 case RTL_GIGA_MAC_VER_35: 4758 case RTL_GIGA_MAC_VER_35:
4680 case RTL_GIGA_MAC_VER_36: 4759 case RTL_GIGA_MAC_VER_36:
4681 rtl_hw_start_8168f_1(ioaddr, pdev); 4760 rtl_hw_start_8168f_1(tp);
4682 break; 4761 break;
4683 4762
4684 default: 4763 default:
@@ -4705,8 +4784,10 @@ static void rtl_hw_start_8168(struct net_device *dev)
4705 PktCntrDisable | \ 4784 PktCntrDisable | \
4706 Mac_dbgo_sel) 4785 Mac_dbgo_sel)
4707 4786
4708static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev) 4787static void rtl_hw_start_8102e_1(struct rtl8169_private *tp)
4709{ 4788{
4789 void __iomem *ioaddr = tp->mmio_addr;
4790 struct pci_dev *pdev = tp->pci_dev;
4710 static const struct ephy_info e_info_8102e_1[] = { 4791 static const struct ephy_info e_info_8102e_1[] = {
4711 { 0x01, 0, 0x6e65 }, 4792 { 0x01, 0, 0x6e65 },
4712 { 0x02, 0, 0x091f }, 4793 { 0x02, 0, 0x091f },
@@ -4719,7 +4800,7 @@ static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev)
4719 }; 4800 };
4720 u8 cfg1; 4801 u8 cfg1;
4721 4802
4722 rtl_csi_access_enable_2(ioaddr); 4803 rtl_csi_access_enable_2(tp);
4723 4804
4724 RTL_W8(DBG_REG, FIX_NAK_1); 4805 RTL_W8(DBG_REG, FIX_NAK_1);
4725 4806
@@ -4736,9 +4817,12 @@ static void rtl_hw_start_8102e_1(void __iomem *ioaddr, struct pci_dev *pdev)
4736 rtl_ephy_init(ioaddr, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1)); 4817 rtl_ephy_init(ioaddr, e_info_8102e_1, ARRAY_SIZE(e_info_8102e_1));
4737} 4818}
4738 4819
4739static void rtl_hw_start_8102e_2(void __iomem *ioaddr, struct pci_dev *pdev) 4820static void rtl_hw_start_8102e_2(struct rtl8169_private *tp)
4740{ 4821{
4741 rtl_csi_access_enable_2(ioaddr); 4822 void __iomem *ioaddr = tp->mmio_addr;
4823 struct pci_dev *pdev = tp->pci_dev;
4824
4825 rtl_csi_access_enable_2(tp);
4742 4826
4743 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT); 4827 rtl_tx_performance_tweak(pdev, 0x5 << MAX_READ_REQUEST_SHIFT);
4744 4828
@@ -4746,15 +4830,16 @@ static void rtl_hw_start_8102e_2(void __iomem *ioaddr, struct pci_dev *pdev)
4746 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en); 4830 RTL_W8(Config3, RTL_R8(Config3) & ~Beacon_en);
4747} 4831}
4748 4832
4749static void rtl_hw_start_8102e_3(void __iomem *ioaddr, struct pci_dev *pdev) 4833static void rtl_hw_start_8102e_3(struct rtl8169_private *tp)
4750{ 4834{
4751 rtl_hw_start_8102e_2(ioaddr, pdev); 4835 rtl_hw_start_8102e_2(tp);
4752 4836
4753 rtl_ephy_write(ioaddr, 0x03, 0xc2f9); 4837 rtl_ephy_write(tp->mmio_addr, 0x03, 0xc2f9);
4754} 4838}
4755 4839
4756static void rtl_hw_start_8105e_1(void __iomem *ioaddr, struct pci_dev *pdev) 4840static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
4757{ 4841{
4842 void __iomem *ioaddr = tp->mmio_addr;
4758 static const struct ephy_info e_info_8105e_1[] = { 4843 static const struct ephy_info e_info_8105e_1[] = {
4759 { 0x07, 0, 0x4000 }, 4844 { 0x07, 0, 0x4000 },
4760 { 0x19, 0, 0x0200 }, 4845 { 0x19, 0, 0x0200 },
@@ -4778,9 +4863,11 @@ static void rtl_hw_start_8105e_1(void __iomem *ioaddr, struct pci_dev *pdev)
4778 rtl_ephy_init(ioaddr, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1)); 4863 rtl_ephy_init(ioaddr, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1));
4779} 4864}
4780 4865
4781static void rtl_hw_start_8105e_2(void __iomem *ioaddr, struct pci_dev *pdev) 4866static void rtl_hw_start_8105e_2(struct rtl8169_private *tp)
4782{ 4867{
4783 rtl_hw_start_8105e_1(ioaddr, pdev); 4868 void __iomem *ioaddr = tp->mmio_addr;
4869
4870 rtl_hw_start_8105e_1(tp);
4784 rtl_ephy_write(ioaddr, 0x1e, rtl_ephy_read(ioaddr, 0x1e) | 0x8000); 4871 rtl_ephy_write(ioaddr, 0x1e, rtl_ephy_read(ioaddr, 0x1e) | 0x8000);
4785} 4872}
4786 4873
@@ -4807,22 +4894,22 @@ static void rtl_hw_start_8101(struct net_device *dev)
4807 4894
4808 switch (tp->mac_version) { 4895 switch (tp->mac_version) {
4809 case RTL_GIGA_MAC_VER_07: 4896 case RTL_GIGA_MAC_VER_07:
4810 rtl_hw_start_8102e_1(ioaddr, pdev); 4897 rtl_hw_start_8102e_1(tp);
4811 break; 4898 break;
4812 4899
4813 case RTL_GIGA_MAC_VER_08: 4900 case RTL_GIGA_MAC_VER_08:
4814 rtl_hw_start_8102e_3(ioaddr, pdev); 4901 rtl_hw_start_8102e_3(tp);
4815 break; 4902 break;
4816 4903
4817 case RTL_GIGA_MAC_VER_09: 4904 case RTL_GIGA_MAC_VER_09:
4818 rtl_hw_start_8102e_2(ioaddr, pdev); 4905 rtl_hw_start_8102e_2(tp);
4819 break; 4906 break;
4820 4907
4821 case RTL_GIGA_MAC_VER_29: 4908 case RTL_GIGA_MAC_VER_29:
4822 rtl_hw_start_8105e_1(ioaddr, pdev); 4909 rtl_hw_start_8105e_1(tp);
4823 break; 4910 break;
4824 case RTL_GIGA_MAC_VER_30: 4911 case RTL_GIGA_MAC_VER_30:
4825 rtl_hw_start_8105e_2(ioaddr, pdev); 4912 rtl_hw_start_8105e_2(tp);
4826 break; 4913 break;
4827 } 4914 }
4828 4915
@@ -6219,6 +6306,7 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6219 rtl_init_mdio_ops(tp); 6306 rtl_init_mdio_ops(tp);
6220 rtl_init_pll_power_ops(tp); 6307 rtl_init_pll_power_ops(tp);
6221 rtl_init_jumbo_ops(tp); 6308 rtl_init_jumbo_ops(tp);
6309 rtl_init_csi_ops(tp);
6222 6310
6223 rtl8169_print_mac_version(tp); 6311 rtl8169_print_mac_version(tp);
6224 6312