|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& a2 F/ T6 I8 E% n#include <linux/init.h>: N2 g+ R' i/ [0 _ G, t
#include <linux/module.h>* p5 a( `9 J+ T9 x% L4 f
#include <linux/kernel.h>: t& ]6 m9 p4 E- r. |
#include <linux/types.h>' v* t3 g5 R) r- X- R- P
#include <linux/gpio.h>4 U2 b- {# F3 w- b/ t6 y3 S F% b
#include <linux/leds.h>
# h, O9 m# l& r# O* n/ J* T#include <linux/platform_device.h> B* ?1 F7 B6 O- S
( ?- H" H. D, ^- l$ h# i% N
#include <asm/mach-types.h>
$ `9 ? X* t- B* G#include <asm/mach/arch.h> f! m7 M' w6 [
#include <mach/da8xx.h>
( |! c$ [: V7 `; M6 ]+ C3 F* R. {#include <mach/mux.h>
! s8 F: W3 g4 u1 G ?
4 H$ _' L5 @3 Y, R# ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 A7 L6 \4 x' V" z. i+ k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& w+ @, e# L& w) e: w% {, d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 ^4 H Q& N: n/ n' B* K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ V3 X3 Y$ F( i% i& r
% ]& {/ C1 s! T# C8 w# g( O* _/* assign the tl som board LED-GPIOs*/9 l2 c3 m( H9 p3 a( I+ q% e! e
static const short da850_evm_tl_user_led_pins[] = {
: o) j0 u2 ~/ k4 `4 m5 X# J3 o /* These pins are definition at <mach/mux.h> file */
: v2 S0 U$ h0 J% x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 e1 _8 Y3 X! m- X% V3 r -1
9 p8 k- W3 W. U1 w8 u};+ r! I! Y; W; T4 L
6 [5 g7 d) P1 V( istatic struct gpio_led da850_evm_tl_leds[] = {
; N; m4 t5 i; |: L9 P {0 J% Z7 k. p9 ~+ [' t
.active_low = 0,. p, [' d# S- F% T2 `
.gpio = DA850_USER_LED0,
3 ?+ G1 {2 f7 f a. b+ @0 Q. d4 U! ` .name = "user_led0",
& s$ F1 Z7 m: d4 Z5 W" }4 |/ [5 s% f .default_trigger = "default-on",
2 {6 _: G o1 C) t5 Z },( w* u' X& \# K) z
{( |# _, E3 ^6 _
.active_low = 0,
7 ?! r6 ^' }+ h* D .gpio = DA850_USER_LED1,
3 d; Z3 D5 R7 }) | .name = "user_led1"," B& j$ @4 ?7 Q1 C
.default_trigger = "default-on",
# O0 k/ {! A. P B },* J4 |- m1 b' a W
{
; X8 u& [2 ^5 K" z .active_low = 0,
' T, }6 _2 j1 G7 M .gpio = DA850_USER_LED2,
2 H2 \% g2 J& x4 b( g0 _' D0 T .name = "user_led2",
* g4 f" R) [5 i" z0 j .default_trigger = "default-on",
& C$ d2 E9 L+ b4 A7 S% w1 { },
; s2 C. q5 G! b( Q' Q# @* P5 ~ {
( H. _% S* z; B% [6 _ .active_low = 0,1 u% f: M4 {; Y
.gpio = DA850_USER_LED3,
/ \7 Q% R; x6 ^0 ~* S! D .name = "user_led3",
- D/ y. F5 S; }0 d" Z/ \( P5 y .default_trigger = "default-on",
8 y+ v1 I4 _2 j: o5 a6 l% t },
0 C* |$ w) Q4 `6 w};$ U2 |" q; I& z2 N" H$ g
, X6 A3 ? B/ ~2 O6 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ c' Z8 I: e8 m
.leds = da850_evm_tl_leds,
- M; g3 n, n! _8 h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* l0 ]" k3 _ e; y8 ^- }: U
};
9 I5 r, t e+ G4 ]
D7 @0 {9 h8 ~: ^static void led_dev_release(struct device *dev)
( u; f. M- o; S1 `( v+ u/ _{
3 B* |: q! ~4 _* ^7 ]. R' R. c& K};
: @ B z& t) C( @
/ y; ?; f: C. z7 n7 G/ H& Zstatic struct platform_device da850_evm_tl_leds_device = {& O. y1 j6 f: F; |- B l' H- g) c
.name = "leds-gpio",
1 ?- s0 ^8 ^' D; r. _6 g .id = 1,4 K/ E& Y/ s, d8 [) @# b" g4 t2 ]
.dev = {; w& f, e, u( k; ^) @! l$ T
.platform_data = &da850_evm_tl_leds_pdata,
1 }; m u5 H, o9 ?& J, e .release = led_dev_release,, }/ E: Y! i7 o
}
/ g7 Q$ ^. ^+ w1 Q( t# N( ?$ E};5 k/ U4 p5 P3 ~' F( S$ J) ~
! @, l. J0 t* y% n. P( Lstatic int __init led_platform_init(void)
" Z' p/ k( k; B0 B u{
1 r c0 o8 X/ B int ret;
/ S ]. m1 T& l; S6 k y#if 02 L" K+ o1 R8 ~% n* Q* V: g" n" g7 C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, v. B W* W6 {) r5 O4 o
if (ret)" `7 ^$ O q, V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" e5 ^ W2 k4 p
"%d\n", ret);
& m# n# q; g+ M$ z# J( w5 r#endif
" \; }' M+ U" U% C/ H9 m' T8 h ret = platform_device_register(&da850_evm_tl_leds_device);
: o1 \4 N H) W5 f& b% n if (ret)
$ L4 D5 e6 U6 x/ v pr_warning("Could not register som GPIO expander LEDS");
. z9 ~/ Q r4 r& z$ X3 C% I9 c else
* h& s% B" U n printk(KERN_INFO "LED register sucessful!\n");5 r' V7 P) r+ Z0 R. f$ Z
+ [. @& ?! e4 _: \5 H0 p; F& [
return ret;
8 t- b- B9 M7 s- r0 t- x" N}7 |5 b1 P: R4 b5 w# [" K% o8 {
. s; H& s$ Q/ s- Kstatic void __exit led_platform_exit(void)* o8 f7 _. u) {3 ]4 ]$ I
{
, F( B( ^3 d K2 ^5 \ platform_device_unregister(&da850_evm_tl_leds_device);
# h% [( y* d; `& f, R( N% b9 L) W4 C0 h$ u" J. u
printk(KERN_INFO "LED unregister!\n");" i3 c8 F' K) }# q4 L& e; p+ m, V
}
9 k* ?; z+ u0 h8 s' \9 f: `5 X! g: X4 [1 X
module_init(led_platform_init);- h. Y9 S W- C T
module_exit(led_platform_exit);
& n/ p1 i2 J3 L! W/ \* b& O+ O
8 ^+ {1 e$ e/ y3 v9 G" {MODULE_DESCRIPTION("Led platform driver");# T' [' X; q# P/ ~' x
MODULE_AUTHOR("Tronlong");3 p- ~% i: `$ K& R w: ^* H
MODULE_LICENSE("GPL");
9 O- L4 i" P7 g" {. p0 S. P2 t: `
# Q7 G7 c) A. x8 M" u0 ] |
|