|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' z/ t( D; P0 X' R& I! n) F4 f#include <linux/init.h>+ o: T5 P4 D6 f! C' C6 }
#include <linux/module.h>
, S5 _2 w( n0 a) p#include <linux/kernel.h>
2 v! [3 C/ L$ S p, s* r#include <linux/types.h>
: r+ U) m: n! _! l9 ~#include <linux/gpio.h>
; Y$ [6 J. }$ a' ~8 f1 z- F! e#include <linux/leds.h>4 r1 t( g5 |* ? m# |- B7 L
#include <linux/platform_device.h>! v: ^, V" T0 J) P0 C8 \
! t8 k @8 A9 C9 e7 i
#include <asm/mach-types.h>! g0 b; ~6 K9 v' O1 E# q
#include <asm/mach/arch.h>
7 q) T, N% M9 t2 b. F#include <mach/da8xx.h>/ e1 P' N2 i( d7 `* N2 o' q
#include <mach/mux.h>. d" b' A. U5 T
3 D: |6 C( `5 X3 {" n6 D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) p( |) X& s* m# r4 S2 a
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. x4 h# ~1 [7 A* h. _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 I/ y k8 b* Z9 U! z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( L2 o- s- o, v' D2 Z3 ^% }6 F9 w4 Z, e/ }- s- b* p
/* assign the tl som board LED-GPIOs*/9 m" I% f: P& v0 z
static const short da850_evm_tl_user_led_pins[] = {" F# A& @+ w( h: m) X( f
/* These pins are definition at <mach/mux.h> file */
6 |- c0 Z& q/ I! \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
n: W% ?' C& U# P7 n8 | -1) @# v& \) D+ x; g! v3 f
};# g8 V( \3 L+ \8 a" B5 p- }
. c) u4 z* r, G# hstatic struct gpio_led da850_evm_tl_leds[] = {
/ f1 E6 Z B. `; q: @# l {
. {- J: }, q5 B) [2 e' l- f2 t0 a .active_low = 0,
4 ]+ y* Z: R [& e# b8 ] .gpio = DA850_USER_LED0,6 o+ v X. I) J1 c( a
.name = "user_led0",
5 w& l, c1 e5 y, y0 {% z .default_trigger = "default-on",
9 w3 n, D8 e k; T },+ X1 W! z% @( C3 t
{8 M& D$ ^2 ^6 B
.active_low = 0,5 k8 T8 L% ~: _. z0 t' ?
.gpio = DA850_USER_LED1,, I4 |0 T# w" r1 G
.name = "user_led1",
$ _! j4 }5 e' `" I& M2 h2 \9 O8 X .default_trigger = "default-on",$ g# `5 M4 H( |% p8 G3 q/ C$ W
},4 D) R$ J9 D3 F, i2 K1 g
{
' u! B4 _. A) x% S% x4 ^ .active_low = 0,
; f( c( B: U# ]' g .gpio = DA850_USER_LED2,4 K5 ?- g5 B$ n% { ^
.name = "user_led2", w& J. [0 K) u1 V1 N2 h: {# T
.default_trigger = "default-on",
) m" U( n, ]7 T0 h/ @6 Z- K' F },
6 `" G; W6 l* \3 K4 v+ V {7 v4 D2 B: l( y) S
.active_low = 0,) N& ` G5 x* k( u9 w
.gpio = DA850_USER_LED3,4 t* M- E8 \" ?7 [, |! o
.name = "user_led3",; C. S0 z( ]2 s; Z4 f" x
.default_trigger = "default-on",
5 P- y9 `! I: g- ] },
- G$ H9 w9 Q* C( x# X$ [; }+ _};9 W5 ?+ O1 r0 p
) [: K3 F" p. i. @: E. K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( f! J" B" j: V2 t& l .leds = da850_evm_tl_leds," e! ~( w) P. M+ m3 j% u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 W' }9 E% ]4 Y
};; P. S, R+ r7 Y
( {$ ?6 E1 U' M1 ~4 W
static void led_dev_release(struct device *dev)! B5 B9 q0 b. K& O
{; b2 f9 I/ T6 V
};6 g; C; z" \, V, l0 T+ z2 O
/ J( R d% v+ D, g4 ~5 `2 v1 g; ^static struct platform_device da850_evm_tl_leds_device = {/ ]6 W0 m: G, O1 U, H. z
.name = "leds-gpio",
5 [: r! r, `) L' d .id = 1,
8 d; S" D% ]# E6 f, U4 p .dev = {6 l- G& Y8 p0 W# Y. R& [1 K
.platform_data = &da850_evm_tl_leds_pdata,& |# O. m9 \. h& a' x
.release = led_dev_release,/ A5 e- f) O% a8 \" K8 T- _
}% O! @# e. U7 A4 D0 c: o
};0 I1 \3 N# s9 \* d
# K8 p6 X- Z2 \+ d8 \: @( _9 bstatic int __init led_platform_init(void): Z9 `' |6 O7 s; A! m' k! k
{3 R. S) ]) r% ]( i- y6 @
int ret;3 K; ?1 \' X! q% ~
#if 0
& D: ~1 Z# {! i, {- k/ H& S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 b# X/ \- `! ~" P* x3 u
if (ret)
; l: I0 O$ g; I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" B/ U' O; J0 e1 E4 c3 F" S
"%d\n", ret); B1 b; z* d. z( w/ ~4 V; u: t, a
#endif- U" q& O9 y( Y; ^
ret = platform_device_register(&da850_evm_tl_leds_device);, b- r8 P+ I1 j- q- H, _' [% m
if (ret)
4 `! A8 V$ d2 @$ p pr_warning("Could not register som GPIO expander LEDS");, v F+ l1 f6 |& W. A+ J" I
else
W. G1 g. ~6 V; X& [" z printk(KERN_INFO "LED register sucessful!\n");
: K- O* i% C0 c6 d2 W8 V" b" h" D1 h) U7 J! b* W
return ret;
4 _" I0 ]3 A# S9 U) b P2 m. k}* M7 v' K% p- E+ A# ~/ `. v: O% g8 Y
% i% q- [! {" ]/ bstatic void __exit led_platform_exit(void)
1 d# x& Y) t" }! _9 j) C{- ?6 S$ a& a, Z& ]
platform_device_unregister(&da850_evm_tl_leds_device);
8 M: c7 | ~$ x( E) u' ]- X4 v) y& C* Z- v6 _4 t& a8 J7 S
printk(KERN_INFO "LED unregister!\n");% s2 Z m7 u) K& B
}" x" K2 P( k; e; d: {- l8 L/ E
: [5 Q, }. q, L& ~, g, i' Y( Xmodule_init(led_platform_init);4 P) o& b2 } {7 _" S: h
module_exit(led_platform_exit);6 r. z: Q5 S. R7 e% Y* h/ c7 U
0 }1 [! W4 V1 f9 B! v. l1 p t6 @
MODULE_DESCRIPTION("Led platform driver");
: X/ `* q. e8 e8 z' g6 CMODULE_AUTHOR("Tronlong");
2 K! W9 F. [3 mMODULE_LICENSE("GPL");/ V& I) `% Q6 i( ?
2 `( z( t( s6 R; h1 \5 T2 M |
|