|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 Z1 L6 F- C# j' h. G5 F4 g#include <linux/init.h>
, e' ?1 |$ W9 W8 @: [; F" p) M' F" \#include <linux/module.h>
{ }: |# e- k8 M, \#include <linux/kernel.h>
0 V' h7 e% z+ n* w- B* M#include <linux/types.h>" U0 R& @1 U6 f, y( T* O) d
#include <linux/gpio.h># h6 x4 y! ~" Y k- M: ~) h. b( x
#include <linux/leds.h>5 R, n, v/ q9 M. j7 F5 q# }6 \. W
#include <linux/platform_device.h>
5 e; S& M$ A9 Z3 V9 c) ~& L3 m! n: f2 k/ Y+ k6 D. V, }' C$ h3 y
#include <asm/mach-types.h>
0 i( ^. t/ B' u, t' f: c#include <asm/mach/arch.h>
9 C+ l1 H" c) X, z: C. b8 I/ ]#include <mach/da8xx.h>) ]% F7 `' A8 d8 R# _0 H" F( i
#include <mach/mux.h>
G4 ~9 H) n$ k9 D0 x2 q7 k# K0 ^7 h) u
/ K( D i, D9 F" J6 u' t" {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 v4 P) ^ M. t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) ?) M9 y0 p+ z* _7 H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 p, R- F$ ^* m# c* E" {8 J1 o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( r- G) W. d* k, q
& Q# ] }' v) I6 e7 \# G3 @! H/ B/* assign the tl som board LED-GPIOs*/: ^/ a% a: ?3 K. Q
static const short da850_evm_tl_user_led_pins[] = {
) B/ A& S* A8 f# w( F /* These pins are definition at <mach/mux.h> file */+ E4 i M7 d- b& I! d7 \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( P! n! p' D( M3 A; O1 M
-1/ J. ]0 E2 J9 K0 o$ `
};
1 u6 d4 k' R1 Y, b, {$ B; @4 w+ ?8 g; @- g
static struct gpio_led da850_evm_tl_leds[] = {3 b2 X8 X3 |; c1 t8 Q' {
{# W2 k6 Y+ H e, a- f
.active_low = 0,1 ?5 P9 Z7 U' ]" d, M7 u* \
.gpio = DA850_USER_LED0,1 u7 j. r6 \% F9 a$ R3 h
.name = "user_led0",- q: P" ^% f/ z6 z" C
.default_trigger = "default-on",
9 B1 ^4 B; [/ T/ J: j1 { A6 x$ ? },/ k; y: n8 f* K- t& c
{
9 l7 K$ [' j8 V .active_low = 0,' W6 ~, F. r/ y; O
.gpio = DA850_USER_LED1,1 X" X; x3 }5 g# k1 r
.name = "user_led1",
- ~9 w0 `2 f4 ?! M7 H6 Q, ~ .default_trigger = "default-on",
7 b! K9 K J7 |( S/ o },
2 K# y! y/ n( h {
. Q/ m2 M: {; W5 }4 o. _ .active_low = 0,. V' X6 r5 Z2 l% s1 C. K; b
.gpio = DA850_USER_LED2,- M' S" a+ F& d2 Z
.name = "user_led2",
/ u0 N9 ]# @* s! |/ w .default_trigger = "default-on",4 [: u1 G, e: M7 ^1 ]
},
, A9 f+ Q! }8 T& y! P {, {9 i. Q1 G0 |( G
.active_low = 0,8 R; K# W4 |" w* W% Q8 h
.gpio = DA850_USER_LED3,
$ y* @# U% K4 [* n# P! D .name = "user_led3",
! h* W0 j3 X' z( z( k .default_trigger = "default-on",
9 @1 G4 q7 p. |6 E },
9 M, {# N' {9 r6 }5 }. `, @};! y' H4 m! [) j7 a% K; v
! `& ?* G. J2 V4 a. ]. }8 Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# C/ D6 o+ t" A7 i& `' ~4 Z .leds = da850_evm_tl_leds,
0 a: _% e& H/ Z/ A6 [9 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, z2 H) O { {+ P};& r; r+ a1 g7 ]5 f$ i* M
' B7 L, Q* x/ F+ O, u
static void led_dev_release(struct device *dev)5 l1 s" K" |5 i7 r. o
{
) V/ [3 |( y x};
! H" \7 A9 |; k' s; n
: c* i! V( n$ c' C& H/ v, Fstatic struct platform_device da850_evm_tl_leds_device = {
) C3 @) Z/ O9 [5 {7 t- t .name = "leds-gpio",& Q7 n- u N6 o. ~3 c
.id = 1,
1 u& y1 U; j( g0 C .dev = {
, w/ H# r* Q5 b, L1 ^7 }7 N/ U2 ] .platform_data = &da850_evm_tl_leds_pdata,5 N$ {( p$ R% @7 y
.release = led_dev_release,' v9 d1 a4 C2 A7 [
}; g/ v+ b" r: H
};
4 k+ a/ X5 c9 ^) N$ c7 |& a" \, ?5 W% g) E: o
static int __init led_platform_init(void)
2 @- H7 B. W& u8 w/ b, u: G{
' x$ r, \0 h' V$ v& x int ret;
0 T/ @ \3 O5 P0 N, b0 \) L9 ^# k S9 i#if 0
: L2 p+ }7 k' ?( x& E9 f8 B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ o2 }1 E9 D2 y) |- P" \2 u% f) W$ c if (ret)
l7 ?4 O: t2 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
N7 c, k3 c! x' @9 \/ X- d- n "%d\n", ret);8 `+ R# I/ f0 U9 ]+ G
#endif
3 N+ m- A. f! Z) T. l3 A D ret = platform_device_register(&da850_evm_tl_leds_device);
$ Q" x( S2 ?) ]. t) O( a8 x5 r if (ret)
1 Y. D3 W! M7 D2 D pr_warning("Could not register som GPIO expander LEDS");" c1 w( y) ?- G \' z6 h
else
) |$ d; e: r2 ?, z printk(KERN_INFO "LED register sucessful!\n");2 K% p# c* O9 R
, F2 t, N% ]0 ]; D- e( H# b5 H return ret;
# g b" W) U6 ~" ]: k$ B& b3 g}% l6 w8 y1 T$ q$ q6 A4 [3 [/ B0 R5 I9 [
# S7 P& k. }6 y7 l: a
static void __exit led_platform_exit(void)' i2 f( i n- t1 c8 y) p7 U
{
) m9 l, D/ w% F+ D platform_device_unregister(&da850_evm_tl_leds_device);
( n! n3 E1 B$ p/ R
1 O9 d# l9 _% C4 f# U printk(KERN_INFO "LED unregister!\n");
$ b# i5 g+ y* U# E" W}9 `! v4 A z6 @' ]* O p
- N" o3 `0 D1 dmodule_init(led_platform_init);
( y: e" @9 o7 t0 q' P7 tmodule_exit(led_platform_exit);, a6 c, ^8 B; b K' { g: y [( O
( \1 s+ G+ s q& \* A$ l, p/ a
MODULE_DESCRIPTION("Led platform driver");
: |1 M0 L; H! GMODULE_AUTHOR("Tronlong");
1 Y$ k! O0 T4 z% ^6 h! c$ N( i' K1 rMODULE_LICENSE("GPL");
4 U7 P3 ]. g( i" P. v8 k; Z# Q( b2 r, h, f4 y* g1 y
|
|