[ar7] correct the MDIO base address and reset sequence for Titan (#6573)
[openwrt.git] / target / linux / ar71xx / files / drivers / net / ag71xx / ag71xx_ar8216.c
1 /*
2 * Atheros AR71xx built-in ethernet mac driver
3 * Special support for the Atheros ar8216 switch chip
4 *
5 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
6 *
7 * Based on Atheros' AG7100 driver
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 */
13
14 #include "ag71xx.h"
15
16 #define AR8216_PACKET_TYPE_MASK 0xf
17 #define AR8216_PACKET_TYPE_NORMAL 0
18
19 #define AR8216_HEADER_LEN 2
20
21 void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb)
22 {
23 struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
24
25 if (!pdata->has_ar8216)
26 return;
27
28 skb_push(skb, AR8216_HEADER_LEN);
29 skb->data[0] = 0x10;
30 skb->data[1] = 0x80;
31 }
32
33 int ag71xx_remove_ar8216_header(struct ag71xx *ag,
34 struct sk_buff *skb)
35 {
36 struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
37 u8 type;
38
39 if (!pdata->has_ar8216)
40 return 0;
41
42 type = skb->data[1] & AR8216_PACKET_TYPE_MASK;
43
44 switch (type) {
45 case AR8216_PACKET_TYPE_NORMAL:
46 skb_pull(skb, AR8216_HEADER_LEN);
47 break;
48 default:
49 return -EINVAL;
50 }
51
52 return 0;
53 }
This page took 0.042426 seconds and 5 git commands to generate.