|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) a9 l1 N* s7 j8 P& a, u#include <linux/init.h>) ^* T Y8 x' U7 ?7 j0 ~
#include <linux/module.h>
/ o; K% Q9 U$ g4 k- Z) S#include <linux/kernel.h>
/ B( f" l& h' l2 } H! F#include <linux/types.h>) N: g# B# J; y
#include <linux/gpio.h>
3 U7 X6 [4 n% M#include <linux/leds.h>/ L- h$ z, [, l6 d- F
#include <linux/platform_device.h>
0 |/ Z/ _6 `7 _+ Q9 R1 e. Q3 I! _6 U4 S8 d: x/ J# p# p3 w
#include <asm/mach-types.h>8 K, z+ ^8 Y2 u( V- P2 ]
#include <asm/mach/arch.h>" v6 M4 W1 v! ~1 ]
#include <mach/da8xx.h>$ t0 H N, f1 i! G
#include <mach/mux.h>
3 b$ l* a" S& f( ?! V" d% w' Z, a; z: Q. E: l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ G5 n$ i0 r5 y2 l% t- \! [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 a. |, x }6 u2 M U8 B; l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 B/ @# G1 q* b6 a$ B- R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ u& |( a3 _9 Z0 H+ p3 ?! ]) f3 ?$ H2 j& m2 x3 ~$ W
/* assign the tl som board LED-GPIOs*/* O: s6 Q2 R8 O
static const short da850_evm_tl_user_led_pins[] = {3 e s% T3 `, |, g; F
/* These pins are definition at <mach/mux.h> file */
5 w/ i3 G' t; }6 m! [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" H V) k& _( w" S -1* _% l$ ]5 D# ]' N" x% j9 @
};
( b2 Z. D$ y! z7 z/ _; E$ F' P& G" L+ l2 C
static struct gpio_led da850_evm_tl_leds[] = {
; E- z" Y0 f& [5 f8 p! U8 h { E0 U4 ^4 {/ a1 a- n! t
.active_low = 0,% S6 h2 b& Q, w, P4 ]4 e
.gpio = DA850_USER_LED0,: o8 {3 b- _8 V/ F6 h7 P# @4 o& D
.name = "user_led0",
4 s5 ]5 ?* Y+ R4 b .default_trigger = "default-on",. O' Q0 l9 `2 {3 E" F/ N/ [: }
},
5 s" F1 {* a( d* u0 ]' P {" S# J0 N D; X. D4 l* `( l
.active_low = 0,2 V# ]$ n' V1 j; U9 _. [9 v
.gpio = DA850_USER_LED1,
' B% V* d) @$ g3 R) Q1 Y/ R .name = "user_led1",
$ a6 q. L* t4 u- V* w .default_trigger = "default-on",1 h, O) o8 [6 Z' N) h, s* s
},
6 S' a; L) X3 c% T k6 F2 V3 p {
0 y8 K5 ~' e2 v6 g( o' f) K2 y .active_low = 0,. M. g, \( Z. \1 s: A6 K* L6 m
.gpio = DA850_USER_LED2,
& O+ f/ A }$ Z( m( j .name = "user_led2",; n6 U/ B/ s0 O c, k* g
.default_trigger = "default-on",
) ^ k0 X' Y- a4 Y N b },9 [0 F b1 N' G7 T
{0 U" w! D4 ~3 \- D* H5 Y( ]
.active_low = 0,
4 Z* y* L( n4 k; V .gpio = DA850_USER_LED3,/ l! W8 [- Q* f! x
.name = "user_led3",
T& m1 I: A F$ S .default_trigger = "default-on",5 o5 L) c4 |' }/ N/ F
},
' ^ E4 Y8 K2 d. c0 C};3 z K; a( R& _7 G, D/ C7 Z
; N5 Q4 K' ~0 m1 O6 a* k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- [7 S2 Y1 |2 ]; E: g% K .leds = da850_evm_tl_leds,. z3 `( G+ ^( @0 g8 D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% f$ A* Y0 i& n4 p};
8 E! \0 {) t8 K
/ b, k! l( |9 t7 I, T6 o( gstatic void led_dev_release(struct device *dev)
& M6 z: c# Z6 w{8 r* M: L" G+ a% Q5 Z1 `# N
};
. m! g% T7 D7 Y7 b) `8 G3 M8 @) M) j0 |8 J* o- B
static struct platform_device da850_evm_tl_leds_device = {: r( s1 F* j; g g
.name = "leds-gpio",2 @1 V/ P5 `1 t/ U
.id = 1,
- K1 h. Z7 w0 X8 ?6 w" ~. g3 D .dev = {
; h: e3 M6 S- I. [, { .platform_data = &da850_evm_tl_leds_pdata,
' P7 [: i' ?" _- B( Y c7 } .release = led_dev_release,
0 d3 C* c6 H G* R+ Y3 z } B! i, ~- e! U& g
};
3 A- \' K5 {0 d- _/ a9 v
/ [& s( P% H7 V. @static int __init led_platform_init(void)
( p( }1 }9 _$ {: ?3 k{
% g( y/ q' V' y4 D int ret;; S0 ~9 j' T1 _% }9 Y$ j
#if 0) B8 ]! u# Y# A1 {8 w) c0 X" Q7 x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 L2 u. F9 f( t+ B! G
if (ret)0 }/ S6 U5 x+ w. y% t/ ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 W* ]9 `! {% K' Y/ `
"%d\n", ret);8 y l2 W3 H9 L- l. W0 E
#endif! V& a4 I" m" s |9 P
ret = platform_device_register(&da850_evm_tl_leds_device);! f: A" K. g! r2 o
if (ret) |1 O* p5 V# \2 Y" y
pr_warning("Could not register som GPIO expander LEDS");
[3 B& _/ c- Z: ? _8 z7 @5 U5 P else* Q4 D( {$ ~1 u0 U+ |7 M8 \( v
printk(KERN_INFO "LED register sucessful!\n");4 \& u& h' h7 U; Q, c
1 p! F$ G% R+ b$ K3 r6 @- j3 ?' q return ret;
. k9 R x. b d1 l}
; O: ~6 r+ G$ @3 X& l) E; @0 ?: Z @6 d& ^! H2 \* p7 Q
static void __exit led_platform_exit(void)" u( c" L0 D; h) g0 r( j1 i/ G
{- b+ q; D3 ^; `4 X" }% c% }8 s
platform_device_unregister(&da850_evm_tl_leds_device);$ K# c$ _$ [ h. |( l+ V- i$ C
- I. @4 i- L; p, n' _# j0 k: m4 M
printk(KERN_INFO "LED unregister!\n");
* Y5 y- V$ j9 G6 u( Z+ \4 [! J7 r$ O}; D3 i2 A i' o9 x
Q) `, g1 D8 [$ P8 ^: tmodule_init(led_platform_init);, k3 l; G8 u" D' V! n
module_exit(led_platform_exit);
7 f) P; V. K V" V# u$ o% s1 \! V* U v# k) e
MODULE_DESCRIPTION("Led platform driver"); ?" ~4 O" w' }4 z9 L4 ]
MODULE_AUTHOR("Tronlong");
5 v" G- _) u1 r- M8 w+ hMODULE_LICENSE("GPL");9 x q$ G* [* V" f/ \
. Y3 i0 e& M7 t7 V
|
|