|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ E5 v* o. D5 D
#include <linux/init.h>
/ h* R% o# W& u7 O" D4 T#include <linux/module.h>
\# X- g u- M: M6 f#include <linux/kernel.h>! S7 M+ j v1 \5 y2 X3 b0 b
#include <linux/types.h>
( h, z. h7 U6 v; q/ x#include <linux/gpio.h>3 a. r" B6 C) C* X d7 ?* e' z6 t o- p
#include <linux/leds.h>- g! e( V3 n7 w1 N1 G% H
#include <linux/platform_device.h>
9 C2 m( ]1 N$ s7 j1 ^% D, b5 Q' J8 H1 C
#include <asm/mach-types.h>
! Q T! r" X# S#include <asm/mach/arch.h>
! @ Q6 w7 l G, {#include <mach/da8xx.h>8 Y( f9 {8 i, N- y
#include <mach/mux.h>1 e6 ^+ E6 [! w9 w) W5 n: f2 |; t
T" j( Q+ T5 f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 V$ \ I: r. d5 ], S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 G- }* V: g f1 P; R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* f2 l8 }" f1 e# _- G4 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 G& G6 n8 w5 T" X- z$ Q
+ Y+ t7 J3 M& ]0 W* ^/* assign the tl som board LED-GPIOs*/ p3 g5 g5 T, Q q6 F t
static const short da850_evm_tl_user_led_pins[] = {
% o' c0 v& k2 ?! Q0 O /* These pins are definition at <mach/mux.h> file */
4 ?+ V/ N! j5 \' R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- N7 n9 R3 b, O' G -1- P$ K9 A6 } J. a8 h1 L
};
k, @$ J/ x8 ~2 a2 ]
% z2 @" s3 ^+ r% L. }& u& ustatic struct gpio_led da850_evm_tl_leds[] = {
5 _5 _9 s7 J. e, p# R6 O {3 z0 b; X+ D3 n5 {5 l d' @0 ~. T
.active_low = 0,6 z- |2 q0 o# k5 q
.gpio = DA850_USER_LED0,
4 K m3 X8 ]' \ w4 N1 } .name = "user_led0",
" a- Q: {% J4 A. l* {; p .default_trigger = "default-on",& {, \! S2 a) M6 A k+ h
},
- {' N5 a6 N) z1 @# k S3 J$ x! O# z { h- ^7 O; q4 ?5 i
.active_low = 0,+ A f( b% K5 D% A
.gpio = DA850_USER_LED1,% a4 t' b$ w, `- D2 o' x( m
.name = "user_led1",
" }, q& i: W6 P5 R1 X/ | .default_trigger = "default-on",% r& f. m" b3 K- Z
},( h3 H, v C8 ~9 [
{0 {9 w" {, N+ s3 r& d) K
.active_low = 0,5 b: G9 M# l! J# P0 _
.gpio = DA850_USER_LED2, o; L- f' ~& S4 g# R2 v# r
.name = "user_led2",
3 Y5 ~% l0 I; N6 N4 u5 Z% V+ e .default_trigger = "default-on",1 k/ Z* r; \1 X$ Z2 b" R0 D
},. K& ^# n- b, I: r- w2 e+ m" ~& B% a
{
|( E1 Z+ Y6 I .active_low = 0,
^* p) p$ {- W( v, p .gpio = DA850_USER_LED3,/ G' o- Z% v4 ^# l
.name = "user_led3",4 P& O x3 U* O
.default_trigger = "default-on",
) U, x0 |; I. i K( s9 { },
) y2 h4 F2 q1 b; M};
' c7 a& S3 f9 c. n. D g
, U. H2 W% Y8 Q0 L# U- [2 ~. sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( t+ U: z1 Q8 b; P .leds = da850_evm_tl_leds,
k/ F3 |0 Y& e+ h" m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& X( d e' t# L* A2 c) C$ P) H};
0 ^7 K3 n3 l9 G; W- G1 [, R% g' y
% Q# e* u# s9 {) k( Kstatic void led_dev_release(struct device *dev)
% _4 h- G$ q+ @& n{( W6 i. L+ b" x# l
};
' c$ H8 y- c, x8 V/ [ T% z5 L4 Y: d6 I7 X' _# q9 P
static struct platform_device da850_evm_tl_leds_device = {
6 x" o2 j" c4 w2 c D: e .name = "leds-gpio",
" e# R2 v( l& {+ W0 f8 S& E/ t .id = 1,3 V$ x$ l3 V! A3 s# l
.dev = {4 a E, u1 z/ u* q
.platform_data = &da850_evm_tl_leds_pdata,
" h4 Y6 O- ^) r; D v .release = led_dev_release,9 g. }$ ?) ]' E0 Z N/ _" U1 @- }
}6 s, v) H" I+ d" U* m* _9 F) S
};( D! {1 ]8 G U6 c) _( U
% C, `7 [$ K; u# y% r
static int __init led_platform_init(void), a3 B& L8 s6 f& ^ x, ~
{2 ^# F8 B( l( B$ @9 L
int ret;
# R- V O4 n ^#if 0
& W) m6 ?# D' t; b8 _0 R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: Q0 `: V- y/ f/ o! b* Q$ F5 ^( G if (ret) b6 w7 M# z+ D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" X8 Z8 J+ S$ Q "%d\n", ret);* C- w5 {# x' S; j( |0 @: J7 ?
#endif2 u r7 _4 E0 J. ]8 o& y
ret = platform_device_register(&da850_evm_tl_leds_device);% i# h3 `* ~* i3 b5 l
if (ret)
1 H, |9 j# B/ E pr_warning("Could not register som GPIO expander LEDS");) R0 M: r# c$ Q+ V Z+ y
else
, q( i& O6 W! W" i9 p printk(KERN_INFO "LED register sucessful!\n");: A, b- n0 c- x. x$ _5 |: }
5 ~8 h( T- \$ d return ret;
9 X( ~" [% Q) F, P" W$ E}4 R( s8 v7 K p- q) Q( Y% o4 b
3 f0 g O9 }" U( }. i' w8 e
static void __exit led_platform_exit(void), Y' l. i2 y: ], I0 x* H% y2 [' ^
{. C7 B3 ~5 _5 N. c
platform_device_unregister(&da850_evm_tl_leds_device);
; B p/ y6 v- _+ ~- n2 ?9 X/ `# N' a6 c- n
printk(KERN_INFO "LED unregister!\n");% h# Y; v, y8 V. k; {
}, D! g" u! q! _3 P
7 {% `% P! ^- Q* H) R) Bmodule_init(led_platform_init);3 g r$ ^2 F* D- z
module_exit(led_platform_exit);
' U) Z; g" @, S1 o c1 v- q" x
MODULE_DESCRIPTION("Led platform driver");
% L4 V7 C5 @9 }2 ]+ yMODULE_AUTHOR("Tronlong");7 L# e- P. M4 y& ~) ~ w
MODULE_LICENSE("GPL");2 m& D$ j9 o* g$ t( N' ? Q
% g0 m2 N6 ^4 o2 Q! s
|
|