|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( g1 M# X& C a' O+ k#include <linux/init.h>
! N" i9 x/ k' C$ @- |1 a, c. T4 H#include <linux/module.h>
& X6 c" O- e; R! ]$ Z) W#include <linux/kernel.h>5 ?9 S( }4 B8 j4 K+ W8 e# h
#include <linux/types.h>$ |# a" v0 z) ^* {! d' x8 Z9 u
#include <linux/gpio.h>
) n6 Y, ~ R4 m* Z#include <linux/leds.h>
7 e- Y: @% ~% @9 T4 P#include <linux/platform_device.h>
/ J- l% m- b, Q; t: d I- K- R
6 v9 ^7 \1 T& G+ w* ]3 i9 d#include <asm/mach-types.h>6 L( B3 H! @! d# `/ L
#include <asm/mach/arch.h>
* z+ y' j) y3 r#include <mach/da8xx.h>
( Z5 K* L: Z8 s2 j#include <mach/mux.h>
8 C/ ~ V# B# W% k/ D) E: K$ w7 T3 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" \( o! B9 F- n( m& ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# {# G, r9 g$ c- y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' e3 d* V' a/ A E& E; }( J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 ?" t9 R& w4 R
8 P0 { Y0 a. O- D$ k$ F3 h/* assign the tl som board LED-GPIOs*/
9 i' `" K& ^. d- hstatic const short da850_evm_tl_user_led_pins[] = {
! Q- y; p. ?. |( T /* These pins are definition at <mach/mux.h> file */
: ^0 b# q' {% C8 q& c& u1 l' W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& {* ?; I7 X& E. T) B
-1 L4 p/ M# ]+ Q# j) |' N' L
};
|7 }1 S! ?) z; w$ E% X8 r) X; ^. C5 ~1 Z4 y' h/ t7 x
static struct gpio_led da850_evm_tl_leds[] = {
7 V) I+ B. j" O% k" q# \$ h {; ] K" z+ B" Q3 {+ k5 z, O
.active_low = 0,
, t. _( |, n9 K .gpio = DA850_USER_LED0,# ]6 p% F8 v6 q9 U+ ?6 v! n8 z( T
.name = "user_led0",
3 c" d% J0 E! y .default_trigger = "default-on",1 Z- \! n1 y, N: q. Y
},
4 T. a8 T5 M" m4 T# Y+ R7 B {
5 E& S# K+ I/ U# V g" l .active_low = 0, L/ _( K2 _- e+ T
.gpio = DA850_USER_LED1,) @1 V. o" J2 i- ~+ P4 N1 G/ f
.name = "user_led1",4 R) D: n8 p9 a4 ]9 h
.default_trigger = "default-on",9 T: k6 D! X: t$ s
},7 G* F) o0 S( L; J; L
{& J3 K( @2 j; D" L$ E m
.active_low = 0,
8 ^4 y5 j' ? [8 L) p; g$ T3 R .gpio = DA850_USER_LED2,
. |# r) X Q* |' U .name = "user_led2",5 Z4 L% l# v6 [
.default_trigger = "default-on",
7 \3 k* Z) P7 V3 n7 ?3 k' G },5 H2 D! E# D- C: `: S' t
{
. w3 V* U- n/ _$ Y$ O .active_low = 0," T0 Q) q# A( F" R
.gpio = DA850_USER_LED3,( G5 h- @8 E' d1 k3 U. o
.name = "user_led3", n. M8 u j' i6 K
.default_trigger = "default-on",
. g8 j. {& s* k },) B5 W% [3 A! Z, _) ~9 |( c8 ^* E% B! i
};
( N) ~0 Z& d; E/ J% r% q5 e9 b2 W0 a( z. v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, D0 p0 i M/ G& P1 u! z) Z$ d |. h .leds = da850_evm_tl_leds,2 R3 v* K! Y) ~7 U0 [7 f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ R) n; }. l! l& n# e2 P
};
2 _9 c& R" h; M) I6 P
. m: U) K% }6 xstatic void led_dev_release(struct device *dev)5 x7 l% k$ I+ y5 u
{
$ Q1 Y# y1 a1 g# S* H. c# S+ Q};& x2 \1 P1 j5 {& c- s% H9 t
6 \# N, E* e7 Y& M( d& Ostatic struct platform_device da850_evm_tl_leds_device = {4 y; ?: H, A( D7 [# g
.name = "leds-gpio",
+ }1 y. N' N- I( G .id = 1,) R/ ~4 P s" b! U% r
.dev = {/ g2 Y# A+ {" \8 X) [: @! P
.platform_data = &da850_evm_tl_leds_pdata,7 g) R& U6 ?! R( x3 \3 C
.release = led_dev_release,
m$ G+ `0 O# J' U } H# E+ q% ?8 b6 Z
};4 @0 K' A4 ^9 w4 ^/ T
- E7 X y( Y+ y, Tstatic int __init led_platform_init(void)
8 Z( A/ R* ]& i/ y1 n{) w* h- p* M8 Q3 n, O! _5 K0 U9 X
int ret;$ g/ |" ~* { S V& m( _
#if 0! \. Y/ v' k% n% h8 ]1 i3 ]0 b3 @. s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 n: j+ O+ [$ e9 c- l7 x
if (ret)' d/ o% Q2 e* z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 g4 d4 R! d2 s1 W+ I% e
"%d\n", ret);4 k9 J* S- ~+ I0 F# l$ {2 u% c
#endif2 _# A; M+ V" e! A( A, y
ret = platform_device_register(&da850_evm_tl_leds_device);$ u" _/ L! H7 w/ T0 Z
if (ret)1 G1 B/ q4 M. X" u% P
pr_warning("Could not register som GPIO expander LEDS");1 S* d7 u q; |- F! S6 N
else
' u8 X9 j! D: {' \ printk(KERN_INFO "LED register sucessful!\n");6 ?* @. U5 f; E. j
7 b+ |/ T9 M& X
return ret; K P' Y2 T5 \8 y) D2 D
}/ f; e6 T- U# Q7 d+ t. O9 z
; r3 ~8 O& |+ F; v1 a
static void __exit led_platform_exit(void)+ @+ Z3 Z1 D' N9 u! I
{& x4 n/ c; I2 t& P
platform_device_unregister(&da850_evm_tl_leds_device);# {2 f6 }! K8 t7 O. O
4 I! r$ i' u. H printk(KERN_INFO "LED unregister!\n");
6 ^% [2 u" b( a/ u3 Y o}$ M6 f- e( ^- D e0 `& u0 D
6 K8 Q/ b0 P9 m( x6 L* U' l
module_init(led_platform_init);
! ]6 X3 d, X- C4 E' G3 Hmodule_exit(led_platform_exit);
9 h, P8 z( v" L) }4 L) A7 U9 M3 N& t& `0 E% C# e
MODULE_DESCRIPTION("Led platform driver");
, O- a$ S; w- p- T7 dMODULE_AUTHOR("Tronlong");( j$ a8 \$ w- ~8 A5 t
MODULE_LICENSE("GPL");' u. L7 B) U( e2 R( m2 Y3 n
$ s! I% }5 |5 M% m$ F |
|