|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" i, r! [6 H7 i; j! U# E& e
#include <linux/init.h>
9 |) Y- a, y9 M# p0 y7 t; y#include <linux/module.h>
$ c+ C0 E- c3 r9 w. z& w% P+ z#include <linux/kernel.h>( w: r2 e7 b! \1 O7 k2 a
#include <linux/types.h>
* s A6 V" p" n+ ?" A7 _#include <linux/gpio.h>
5 p5 O# W, W4 r1 A9 A* u#include <linux/leds.h>
, e& @7 K7 Q2 H3 R& l ^" x#include <linux/platform_device.h>9 v$ |; s! x5 v' Z2 t! |
3 u6 g, O% D& D
#include <asm/mach-types.h>
8 s) W; h3 F; Z; h0 B% P#include <asm/mach/arch.h>
8 |; q/ K& u3 Q/ }#include <mach/da8xx.h>
! q/ F4 q( A4 k: l2 F' g1 A. W! i#include <mach/mux.h>
3 P! i1 V! b$ p2 |# Z# Z6 _8 E; [' m/ i4 _ b, ~( b8 b% s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ W9 Y9 [. ? Z1 Q' |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# A& Y- E% y0 k4 w1 w ]$ ?+ U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 l7 ~2 W' p) I! n( I1 A* s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 z: H7 B4 J+ F, Z4 V- Z; ]
3 g. z" N) @, e4 c, |0 Y8 y/* assign the tl som board LED-GPIOs*/1 {+ W, S0 K3 S6 X- K k3 @
static const short da850_evm_tl_user_led_pins[] = {' {6 N7 j8 _4 r% x# }; M
/* These pins are definition at <mach/mux.h> file */$ y+ D8 |2 ]/ U6 \" Y1 s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 N- j: ?& |( T# L- |
-1. C: Y6 I1 H+ Q, C6 J/ w/ m0 a
};
! v5 }# p/ z* r4 g4 u4 q* x
& q( z0 }$ ^/ j3 y a: c- ~static struct gpio_led da850_evm_tl_leds[] = {
" o/ d( c+ t; r6 ?3 Z {
0 G f) d) Y J/ H, f8 Z$ B9 Y .active_low = 0,
1 ]: j9 x6 t$ C9 e0 V& ~. f .gpio = DA850_USER_LED0,
4 A. \: ~. O* m2 b8 s' n p .name = "user_led0",& `, \" f/ h; {& }+ k) U# k
.default_trigger = "default-on",) N8 H" V7 c+ F6 q8 ~7 I
},
+ w2 ^7 T: U# U% J7 R% x: ?5 k {
+ P' P( l" Z8 g) [' x% _ .active_low = 0,
# b7 d- @2 M3 t4 O .gpio = DA850_USER_LED1, [" g$ p; w" r0 H
.name = "user_led1",
. L" T$ L) Y. B' c5 L .default_trigger = "default-on",
c1 F" X& _9 f* S/ P* z" a },) {$ S, {) t9 ?+ d, n/ j
{+ u* {8 d( U( A0 h" ^
.active_low = 0,
: y; U( ]' ` V5 c# }% s( n7 C) W; | .gpio = DA850_USER_LED2,$ n& j+ _1 w( c$ u- \
.name = "user_led2",
- s: q( f% R% p/ O t9 n! l .default_trigger = "default-on",
' ]/ x( T7 M* G/ G; `: I },
2 _$ Z3 r4 Y& r- S4 o* j8 `& m: V7 g {- |6 H9 E y+ T% T+ s. A) C2 O
.active_low = 0,
3 h/ \% W# ]. Q0 { .gpio = DA850_USER_LED3,
: C. @9 n! f) s; \% g .name = "user_led3",& r1 W/ n7 h8 q; y
.default_trigger = "default-on",+ W4 J! i/ s/ F7 g! Q
}, G4 s) O$ V. p5 {, |9 P* M2 o
};
* A4 z" h; B7 X6 l [1 r0 c A4 Q! A; U+ x# X& b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* V* x$ \% s2 G: f( m .leds = da850_evm_tl_leds,9 Y$ e" A, c+ K% b5 K" h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! M2 D% W3 \: i
};
1 ~3 L# \* c/ R; a) h) a
2 m* n0 g0 R' ~9 {- C1 `7 h: Zstatic void led_dev_release(struct device *dev)
2 x& c; c! v3 ^9 [7 t" g G{! v3 e0 Q7 q" t( `, e5 v
};9 D! q Z# l/ e3 ^# u4 ]+ M) {
4 ~: k9 z+ K: Q5 p5 J, ?static struct platform_device da850_evm_tl_leds_device = {
+ \0 F! P" J" S" R1 K7 n, L .name = "leds-gpio",
. L0 m+ H* _' v2 p% d7 q; V4 N6 X .id = 1,
- N' B ^. B8 r3 B; _ A .dev = {
; z! C8 n' F m/ I- X; F1 a, c .platform_data = &da850_evm_tl_leds_pdata,
~* S$ i* `- G9 ~: B# Q7 s$ @ .release = led_dev_release,
- {6 e6 [, f$ \( w/ d' E }
8 t, b' I w3 s};0 L7 Z l) W: w, w9 l" F
, z- C% ?% Y2 @ H8 Ystatic int __init led_platform_init(void)
1 P, ~* u: D( m7 C/ g2 e; ~/ L{
5 v+ [+ u6 y" u1 @. k! ^; p int ret;
$ Z) {7 k! }( A#if 0
* f- V4 o' I3 @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" ]- X& a2 A, t
if (ret)
1 x0 s5 V4 w+ q, F6 e, a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 G" N0 J$ f/ {6 E, a& @
"%d\n", ret);
0 }' {+ [" M9 O( S8 n U#endif
0 `, k* k; `2 G$ w+ I1 B ret = platform_device_register(&da850_evm_tl_leds_device);
9 a/ z& n% H0 T if (ret)$ [4 e& W- |9 W) [* }% m
pr_warning("Could not register som GPIO expander LEDS");
! R- n% z# ?* J! ^ else2 `% ^) h% F. Y9 U6 f/ f3 [; k
printk(KERN_INFO "LED register sucessful!\n");
$ Y1 H6 ]- Q' U3 i" b
4 W! O0 H% _6 l return ret;
' M7 F. l) M3 o2 ]2 ]; ?$ Y2 _9 U}. V, T! T; P7 w8 p; |2 @ S! n
0 P( S3 @5 q* ?static void __exit led_platform_exit(void); j8 e% P' A! }
{
. J8 O" @3 v! { platform_device_unregister(&da850_evm_tl_leds_device);
) v% u! J( p; k% B& D' z
, D0 q: r6 ~% R printk(KERN_INFO "LED unregister!\n");
# t) V$ n$ K2 h, m) H0 o J}! [; d. t& y4 Y. H* [8 L2 A
* Y/ r6 [% c$ e: E6 F7 ]! D- Z
module_init(led_platform_init);2 J" ~2 q& o/ ]9 B X
module_exit(led_platform_exit);7 l; f! H7 o; f5 z
3 H, v2 _" ~% q% S& y8 X- ]
MODULE_DESCRIPTION("Led platform driver");
; `: b0 y7 w- L/ h# xMODULE_AUTHOR("Tronlong");
& X$ t* Y, B( }. CMODULE_LICENSE("GPL");
, d( I7 J1 {8 Y( w1 I, _$ d4 d' S# O8 t( }: ?( d0 m
|
|