|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# w5 j& n, S7 |2 k3 a#include <linux/init.h>: r% W( O( ~6 @+ e
#include <linux/module.h>
9 |+ V8 _6 W9 C& k' C#include <linux/kernel.h># t; k& Y3 Z0 }6 q4 F6 e
#include <linux/types.h>+ S$ }& K4 Y, r- [; g0 R8 B+ y; m
#include <linux/gpio.h>
/ \ ] x6 \3 \#include <linux/leds.h>( {: c$ q4 m y4 X+ s# f. [1 Q
#include <linux/platform_device.h>
0 f; l! B6 `+ t/ T) o, n) ^: H1 { p/ }
#include <asm/mach-types.h>+ g1 C' j8 f% s* Q: S: T% r) R
#include <asm/mach/arch.h>
$ w5 s2 r( r1 D3 c" M! w) q#include <mach/da8xx.h>
! G0 A3 Q/ {- \7 o9 a$ o#include <mach/mux.h>
: u4 K# U* h. e* c" L; o
/ ~; {, {* h# m' h; y3 r% e. R2 @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 w2 H J6 E5 B- M3 ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ M. I3 f& M) z6 l& J; c* e' n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 Y8 O/ W- @/ M# f! E( q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: {. f+ x4 H. t) n
6 g. ~. L! d; {/* assign the tl som board LED-GPIOs*/
/ D6 j4 U+ [; P8 G7 P0 D& C R. cstatic const short da850_evm_tl_user_led_pins[] = {6 O4 V7 s$ |5 b9 H2 L3 ~! [
/* These pins are definition at <mach/mux.h> file */
% F" R# N7 X$ K' J. g3 R4 I( d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 q" [) p7 N# l9 r$ G; ?/ x2 B
-1
$ i6 N2 ?- v( z' p% U4 k5 c0 B" p7 A};( }3 i, U& @- B# Y% c# ^
7 L5 K- O' ]5 j% b- a& u7 ?static struct gpio_led da850_evm_tl_leds[] = {$ d: h' o, g8 o& Z
{ f. j; ?( H* Z
.active_low = 0,
: O3 a4 C, M8 d2 ~8 U .gpio = DA850_USER_LED0,. J+ \5 v. z& L) P7 k/ n7 r C
.name = "user_led0",
5 \! E. T: w$ I7 P4 i .default_trigger = "default-on",
+ P) O0 c% {' J e0 u. G7 R! w },
' K, k |* f0 W5 n) h {
1 m" @, e3 b6 j .active_low = 0,% e) f5 a7 k+ }3 t" f
.gpio = DA850_USER_LED1,- V/ b$ E1 |# E2 s" g
.name = "user_led1",
# Y. J8 V0 l5 u; @ P3 y% _ .default_trigger = "default-on",
$ Z+ a$ [" k- u2 ]5 g1 `, n! o/ z },8 k. t/ M1 y# n
{
, O5 X5 ?) }( t6 L# p .active_low = 0,
- a, Z h# I+ y8 ^7 P0 U+ G' V .gpio = DA850_USER_LED2,# T9 A+ n0 o" Y# P9 B
.name = "user_led2",/ y. G8 k2 j: v8 H$ w6 B
.default_trigger = "default-on",+ I. L! v/ k/ {5 Y% A. n8 B1 v# [
},0 w7 F) f+ k8 E. K" B% C( W
{ r3 c; z9 Y, i ?
.active_low = 0,
: r4 Y% |* ~ ^* G! z9 x .gpio = DA850_USER_LED3,
/ g7 X* {# F4 k7 [6 M2 w0 A .name = "user_led3",$ [! i0 P6 j& ^8 W
.default_trigger = "default-on",
( M: k: f' A$ Z, W, b: g },, Y' T5 d& E9 V3 j$ ]' o
};* k" P) t8 x) [! s
$ O6 c% h7 K. D9 f1 Y- `! ]; S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 b, {" L& j* Q# V( S$ C) k8 @; ^ .leds = da850_evm_tl_leds,
* _" K& y1 }; G3 L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. n( _; b9 i" b+ d) @$ \& ^. Z
};
% e/ W) e" Z/ S4 }3 Q( k0 k+ Z2 K3 B) v2 F# {+ d
static void led_dev_release(struct device *dev)
9 r. f. z' Z8 [3 [{
9 P% N" }& O" l4 L, O0 Q, {" [};
8 h0 H. x: n% O e3 p" i% j' M: ~! e2 ?+ u
static struct platform_device da850_evm_tl_leds_device = {
, @' \1 a8 \# j .name = "leds-gpio",0 U0 I) [8 I* f2 i
.id = 1,
* ]# `4 ^) v( y1 I4 Y [" U .dev = {
0 ]# }0 k" o \, s .platform_data = &da850_evm_tl_leds_pdata,; l9 j+ v$ _4 O" U$ Q3 C& K
.release = led_dev_release,
* F/ U' C0 ?1 n, o; I$ E }
- D5 V* c/ n* S. {% Z" u: l% B};4 r1 R" N" `2 K! o3 [: {
* C) r8 x1 W; U0 E+ X
static int __init led_platform_init(void)
7 e! P, U. Y9 K/ n& V{
8 p) L* y7 A. d2 e int ret;
* \" O f& {9 u/ o, g- ~8 o#if 0, r" z' [8 C' K, V. [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ P8 {5 y X8 F, C2 q
if (ret)! s" A8 `. r1 E! {* p2 }$ ]4 H0 O; R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& r" J3 u7 X1 z3 b& L4 c" e( Y, P* s
"%d\n", ret);' x6 n* J! H P* F; A) x% C. \
#endif
9 i* D4 n7 x+ l9 s ret = platform_device_register(&da850_evm_tl_leds_device);
a* W+ [. q) Q if (ret)% {$ ~' q* _- J' { ^: V
pr_warning("Could not register som GPIO expander LEDS");
& V; ?& e# I; e( A# ^' e! W else1 `, c! T( Q7 G# d$ o3 n K
printk(KERN_INFO "LED register sucessful!\n");
& w" [3 e) R( I7 L; z1 j5 K
3 a) x' Z' Z; D3 v; y return ret;7 {) [9 J' j: @$ I: X5 Q7 H
}( g2 H7 | G4 h& t, x" ~
- \9 S! U2 q: Y
static void __exit led_platform_exit(void)
0 I, E" M2 w: ?$ W- e' N7 v8 y{1 ]) t0 L) r$ q4 j2 { K
platform_device_unregister(&da850_evm_tl_leds_device);
. G* R) b1 [1 r1 q( U
0 _$ j9 n; k2 b+ \ s8 g printk(KERN_INFO "LED unregister!\n");
Z7 R1 n5 ]8 i5 Q1 M& q# O# j}9 n) T: V% H# e3 [5 ^( N
- E! O* i" s: v: V; _module_init(led_platform_init);
! Y J: M [# P- K3 B/ b# r$ Jmodule_exit(led_platform_exit);
4 w3 K5 Y/ `6 n* z( u& j
7 D, g! z# o- r" [* `MODULE_DESCRIPTION("Led platform driver");
7 X1 o; R2 q( o& w) ?8 WMODULE_AUTHOR("Tronlong");& w9 ~. T9 M- u m9 e% Y
MODULE_LICENSE("GPL");8 Z$ Z e; [8 I
$ T3 T) G Z; Q* Z6 s; O
|
|