|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% i; L2 D' N( T$ N% R3 l#include <linux/init.h>; S# Q) H3 F( G0 O0 P
#include <linux/module.h>6 I& k2 ~5 {/ [7 A" O$ k% ]
#include <linux/kernel.h>$ c! [" |8 o! {. X* Z6 y4 I
#include <linux/types.h>
) m- H/ h& L6 `0 u2 O' c3 k; W#include <linux/gpio.h>, G. F1 g3 n0 {- T
#include <linux/leds.h>0 ~0 }! |) _; i/ ~: `
#include <linux/platform_device.h>
% s: B7 E: g; ]
6 ~) K' i% b) n& [/ M#include <asm/mach-types.h>
, B) E8 @6 m6 f$ Z% ^- e0 h8 R6 y#include <asm/mach/arch.h>
8 s/ T2 r' R: ~/ N#include <mach/da8xx.h>! l+ U7 h* C. w- H7 s
#include <mach/mux.h>
0 u d& T: g5 `1 B7 l( e' t) ]3 b0 |6 @6 w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): i6 n& @9 n9 a9 [/ ^. k0 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! T( Q# f9 g. N& D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 M8 p2 K& P! C$ @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( T: Q" Y$ X3 Z
& O; R8 P5 \: s- R0 C X7 S3 r
/* assign the tl som board LED-GPIOs*/' @4 ?: [& M7 @1 B! C4 W+ P
static const short da850_evm_tl_user_led_pins[] = {
{' H" z1 U5 L0 f# M /* These pins are definition at <mach/mux.h> file */
- w3 {4 R9 X5 W# G3 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, e( \$ j* K& b9 w3 N5 p3 M -1
# ?. S$ \, O/ E};
2 O2 T2 l4 @- _& L# M' I: ?
$ a m4 _* i4 L; \4 X* @& qstatic struct gpio_led da850_evm_tl_leds[] = {
- q0 Z, V+ {" G$ K* w {; S) X! b- r( x9 q: Q" e
.active_low = 0,1 F% q# z k7 w/ A2 j. \
.gpio = DA850_USER_LED0,6 o; U# r# y9 ^5 b4 M
.name = "user_led0",
- g- j. C7 L% Q* Q3 i .default_trigger = "default-on",
" d0 m+ I, L7 }; A; D8 @6 ? },
& n' Z( W* k8 e, ?$ f4 k {
& @0 {% }- [; q% U .active_low = 0,
9 B2 Z, d; o4 S( R# ^ .gpio = DA850_USER_LED1,
6 j! {- o6 Y. x! { .name = "user_led1",# l$ \7 L( G* t
.default_trigger = "default-on",
9 | n0 P: ^: V$ ?0 {: X: O6 I5 d },
6 {1 `4 S+ f& S. X% ^0 e {
2 M# w: @! _4 Z8 b! b8 P .active_low = 0,
8 X( a( B+ b+ l/ D .gpio = DA850_USER_LED2,
4 |: I" `" a* U .name = "user_led2",
6 F/ H2 K, T: [& B9 x0 @# B" G .default_trigger = "default-on",
0 p& e9 A3 c2 S( d },1 R( c @8 A/ m5 z/ Y
{
+ I! l& M! ?" D: w .active_low = 0,$ a- X) {: L( R& v
.gpio = DA850_USER_LED3,4 G' l, P% ~0 H* B0 z$ z
.name = "user_led3"," g: ~! v; l6 o
.default_trigger = "default-on",7 U; s9 D1 ?6 W, B/ m% H) S' l9 {
},2 l3 D( r* L" r6 c
};
# R* ?, ]3 K% ^: i, B* `% p, |+ `/ L; G' u0 L6 U/ i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 z4 p X+ n! X4 Z( a. w Q .leds = da850_evm_tl_leds,( `2 m/ D8 c9 h, r/ ^2 b- g. {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 x9 Q/ ~5 I. b6 [3 A0 r6 z" S};+ t8 X) {8 S, {0 U' p2 W
( p. [, X( M/ k0 G& K/ J
static void led_dev_release(struct device *dev)
1 O, V' d+ N0 w4 }. c0 T9 B( t{/ X+ E& ^- K0 y
};
! V1 P2 H+ q1 L# ^
5 c7 k K* T& a4 c5 k# D" istatic struct platform_device da850_evm_tl_leds_device = {
' Z- L9 t" \, G! _2 K .name = "leds-gpio",
* ?$ O+ j5 _" w1 D7 y* h# B .id = 1,% L* {% z3 T3 n) ^' d
.dev = {2 [9 s# q; Q: Z# q/ X9 P3 b0 K% ^3 z
.platform_data = &da850_evm_tl_leds_pdata,
9 Z" i+ N/ M( S6 m .release = led_dev_release,+ X0 f2 J& w, o+ _4 n
}
2 [8 P$ M2 U# C' Z1 s};+ J) R( D5 K. H
' H+ z. o8 B" {5 q& b7 b+ cstatic int __init led_platform_init(void)
" T4 p& f3 h& X. `! k9 f+ R" n. H{' c% j9 s; U+ ^ B/ f$ R j/ d
int ret;1 h' v% G" Y/ t# X! V" d9 k! ^
#if 03 L9 W9 p# m* _+ u! x" e# G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 A/ \8 q2 H1 Z& V9 u" d
if (ret)) d, y% D. t8 r5 d& k+ J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 L: V) N, ~% `& }
"%d\n", ret);
" N2 M1 P8 L4 _. D- q#endif' ?1 @8 B% q0 h
ret = platform_device_register(&da850_evm_tl_leds_device);* G& n k& x3 G
if (ret)
7 P0 W l2 I( X+ |7 O9 c; o* X# R pr_warning("Could not register som GPIO expander LEDS");7 F( A( }: T; E' ^
else- ]' A3 R/ X& Q" D( f I
printk(KERN_INFO "LED register sucessful!\n");
, l' T4 [7 J0 F4 p5 {5 W+ M+ U, G q, K+ o J* Q
return ret;- [' ]" u. q( x/ F: l
}* g e2 ]5 R$ Y. `) N- ]
9 I& e! b+ j% w. R% P* O
static void __exit led_platform_exit(void)' z4 w( r: Q+ M. i5 Y& P
{* k2 R: n; F3 J ~/ b0 O
platform_device_unregister(&da850_evm_tl_leds_device);
1 d* H w9 |2 E9 E m% r- ]% a! N# \
printk(KERN_INFO "LED unregister!\n");
1 R- x- l, l* m# S v}% i8 N: o1 m; c+ X% K# e
3 I/ j5 ]' y+ d
module_init(led_platform_init);
8 _& K( ~3 Y+ |+ H* W$ ]6 wmodule_exit(led_platform_exit);/ K0 ?+ M/ w$ k- K U
: @8 ^/ |1 \0 a& B4 _ T
MODULE_DESCRIPTION("Led platform driver");
; n% Q/ R7 M zMODULE_AUTHOR("Tronlong");0 _, e. R6 x+ K7 X$ Z1 U: _
MODULE_LICENSE("GPL");8 `- H6 o2 }/ T+ d3 T! e" `
8 u8 M7 _; ?* b- I/ n8 S, y0 U7 q" [
|
|